:root {
    --bg-gradient: linear-gradient(135deg, #f5f7fa 0%, #e4e9f2 100%);
    --glass-bg: rgba(255, 255, 255, 0.65);
    --glass-border: rgba(255, 255, 255, 0.4);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
    --primary: #4F46E5;
    --primary-hover: #4338ca;
    --success: #10B981;
    --danger: #EF4444;
    --text-main: #1F2937;
    --text-muted: #6B7280;
    --highlight-bg: rgba(251, 191, 36, 0.4);
    --highlight-border: #F59E0B;
    --highlight-hover: rgba(59, 130, 246, 0.3);
    --highlight-converted: rgba(16, 185, 129, 0.2);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Noto Sans JP', sans-serif;
    color: var(--text-main);
    background: var(--bg-gradient);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    position: relative;
    overflow-x: hidden;
}

.app-background {
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 50% 50%, rgba(99, 102, 241, 0.1) 0%, transparent 50%),
                radial-gradient(circle at 80% 20%, rgba(16, 185, 129, 0.1) 0%, transparent 30%);
    z-index: -1;
    pointer-events: none;
}

.container {
    width: 100%;
    max-width: 1200px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.ai-controls {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    background: rgba(255, 255, 255, 0.75);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 0.7rem;
    padding: 0.45rem 0.65rem;
    font-size: 0.85rem;
}

.ai-controls-label {
    font-weight: 700;
    color: var(--text-main);
}

.ai-controls label {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    color: var(--text-muted);
    font-weight: 600;
}

.ai-runtime-status {
    font-size: 0.82rem;
    font-weight: 700;
    border-radius: 999px;
    padding: 0.35rem 0.65rem;
    border: 1px solid transparent;
}

.ai-status-idle {
    color: var(--text-muted);
    background: rgba(107, 114, 128, 0.12);
    border-color: rgba(107, 114, 128, 0.2);
}

.ai-status-on {
    color: #2563eb;
    background: rgba(37, 99, 235, 0.12);
    border-color: rgba(37, 99, 235, 0.24);
}

.ai-status-off {
    color: #b45309;
    background: rgba(180, 83, 9, 0.12);
    border-color: rgba(180, 83, 9, 0.22);
}

.ai-status-error {
    color: #b91c1c;
    background: rgba(185, 28, 28, 0.12);
    border-color: rgba(185, 28, 28, 0.22);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo .icon {
    font-size: 2rem;
}

.logo h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.75rem;
    font-weight: 600;
    color: #111827;
    letter-spacing: -0.5px;
}

.main-content {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
}

.editor-section {
    flex: 1 1 65%;
    display: flex;
    flex-direction: column;
    min-height: 600px;
}

#text-section {
    min-height: 470px;
}

.sidebar {
    flex: 1 1 35%;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    position: sticky;
    top: 2rem;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 1.25rem;
    box-shadow: var(--glass-shadow);
    padding: 1.5rem;
}

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

.section-title {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.9rem;
}

#editor {
    flex-grow: 1;
    font-size: 0.95rem;
    line-height: 1.6;
    outline: none;
    padding: 1rem;
    border-radius: 0.75rem;
    background: rgba(255,255,255,0.4);
    border: 1px solid transparent;
    transition: all 0.2s ease;
    white-space: pre-wrap;
    min-height: 260px;
    max-height: 320px;
    overflow-y: auto;
}

#editor:focus {
    background: rgba(255,255,255,0.8);
    border-color: rgba(79, 70, 229, 0.3);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}

#editor[placeholder]:empty:before {
    content: attr(placeholder);
    color: var(--text-muted);
    opacity: 0.6;
    pointer-events: none;
}

.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.9rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(0,0,0,0.05);
}

.counts {
    display: flex;
    flex-direction: column;
}

.char-count {
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--text-muted);
}

.char-warning {
    color: var(--danger);
    font-weight: 600;
    font-size: 0.9rem;
    display: none;
    animation: flash 1s infinite alternate;
}

@keyframes flash {
    from { opacity: 1; }
    to { opacity: 0.6; }
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    border: none;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    border-radius: 0.5rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.4);
}

.btn-secondary {
    background: white;
    color: var(--text-main);
    border: 1px solid #e5e7eb;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.btn-secondary:hover {
    background: #f9fafb;
    border-color: #d1d5db;
}

.btn-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.btn-success:hover {
    background: var(--success);
    color: white;
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
    background: var(--danger);
    color: white;
}

.btn-icon {
    padding: 0.4rem;
    background: transparent;
}

.loader {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.highlight {
    background-color: var(--highlight-bg);
    border-bottom: 2px solid var(--highlight-border);
    border-radius: 2px;
    padding: 0 2px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-block;
    position: relative;
}

.highlight.hovered {
    background-color: var(--highlight-hover);
    border-color: var(--primary);
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    z-index: 10;
}

.highlight.converted {
    background-color: var(--highlight-converted);
    border-color: var(--success);
}

.suggestions-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.suggestion-box {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 1rem;
    padding: 1.25rem;
    box-shadow: 0 4px 16px rgba(0,0,0,0.04);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: center right;
}

.suggestion-box:hover, .suggestion-box.active {
    transform: translateX(-5px) scale(1.02);
    box-shadow: 0 8px 24px rgba(0,0,0,0.08);
    border-color: rgba(79, 70, 229, 0.3);
    background: rgba(255,255,255,0.9);
}

.suggestion-content {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.suggestion-reason {
    font-size: 0.85rem;
    color: var(--primary);
    background: rgba(79, 70, 229, 0.1);
    padding: 0.6rem 0.8rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    line-height: 1.4;
    border-left: 3px solid var(--primary);
}

.suggestion-word {
    color: var(--danger);
    font-weight: 500;
    text-decoration: line-through;
}

.suggestion-arrow {
    color: var(--text-muted);
}

.suggestion-replacement {
    color: var(--success);
    font-weight: 700;
    font-size: 1.2rem;
}

.suggestion-actions {
    display: flex;
    gap: 0.5rem;
}

.suggestion-actions button {
    flex: 1;
}

.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    background: var(--glass-bg);
    border-radius: 1rem;
    border: 1px dashed rgba(0,0,0,0.1);
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.6;
}

.empty-state .emoji {
    font-size: 3rem;
    display: block;
    margin-bottom: 1rem;
    opacity: 0.8;
}

.hidden {
    display: none !important;
}

.history-list {
    list-style: none;
    font-size: 0.9rem;
    max-height: 300px;
    overflow-y: auto;
}

.history-list li {
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-list li:last-child {
    border-bottom: none;
}

.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #1F2937;
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 2rem;
    font-weight: 500;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 100;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.ui-lock-overlay {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.35);
    backdrop-filter: blur(2px);
    z-index: 120;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ui-lock-card {
    background: rgba(255, 255, 255, 0.96);
    border-radius: 1rem;
    padding: 1rem 1.2rem;
    min-width: 260px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.2);
}

.ui-lock-spinner {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid rgba(79, 70, 229, 0.25);
    border-top-color: var(--primary);
    animation: spin 0.8s linear infinite;
}

.lock-message {
    color: var(--text-main);
    font-size: 0.92rem;
    font-weight: 600;
}

@media (max-width: 900px) {
    .main-content {
        flex-direction: column;
    }
    .editor-section, .sidebar {
        flex: 1 1 100%;
        width: 100%;
    }
    .sidebar {
        position: static;
    }
}
/* Tabs */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: -1px;
    z-index: 10;
}

.tab-btn {
    padding: 0.75rem 1.5rem;
    border: 1px solid var(--glass-border);
    border-bottom: none;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 1rem 1rem 0 0;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(8px);
}

.tab-btn.active {
    background: var(--glass-bg);
    color: var(--primary);
    border-bottom: 2px solid var(--primary);
}

/* Drop Zone */
.drop-zone {
    flex-grow: 1;
    border: 2px dashed rgba(0,0,0,0.1);
    border-radius: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    background: rgba(255,255,255,0.2);
}

.drop-zone:hover, .drop-zone.dragover {
    background: rgba(255,255,255,0.5);
    border-color: var(--primary);
}

.drop-zone .icon {
    font-size: 3rem;
    opacity: 0.5;
}

/* Image Preview */
.image-preview-container {
    flex-grow: 1;
    position: relative;
    border-radius: 1rem;
    overflow: hidden;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-preview-container img {
    max-width: 100%;
    max-height: 400px;
    object-fit: contain;
}

.image-preview-container .btn-danger {
    position: absolute;
    top: 1rem;
    right: 1rem;
}
.pdf-icon {
    font-size: 3rem;
    font-weight: bold;
    color: #FF5722;
    background: rgba(255, 255, 255, 0.9);
    padding: 1rem 2rem;
    border-radius: 0.5rem;
    border: 2px solid #FF5722;
}

.file-name-display {
    position: absolute;
    bottom: 1rem;
    left: 1rem;
    right: 1rem;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    border-radius: 0.4rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
}

.text-xs { font-size: 0.75rem; }
