/* ===== DESIGN SYSTEM ===== */
:root {
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-card: #1a2035;
    --bg-card-hover: #1f2842;
    --bg-input: #0f1628;
    --border-color: #1e2d4a;
    --border-hover: #2d4a7a;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --primary-glow: rgba(59, 130, 246, 0.15);
    --primary-soft: rgba(59, 130, 246, 0.08);
    --success: #10b981;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --danger-soft: rgba(239, 68, 68, 0.1);
    --warning: #f59e0b;
    --text-primary: #e5e7eb;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --mic-active: #ef4444;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --shadow-card: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.5);
    --transition: 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ===== ANIMATIONS ===== */
@keyframes fadeInScale {
    0% { opacity: 0; transform: scale(0.97) translateY(8px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes modalPop {
    0% { opacity: 0; transform: scale(0.92) translateY(15px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes fadeIn {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

/* ===== SECTIONS ===== */
section {
    display: none;
    min-height: 100vh;
    flex-direction: column;
}
section.active {
    display: flex;
    animation: fadeInScale 0.35s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.hidden {
    display: none !important;
}

/* ===== AUTH ===== */
#auth-section {
    justify-content: center;
    align-items: center;
    background: var(--bg-primary);
    background-image: 
        radial-gradient(at 20% 50%, rgba(59, 130, 246, 0.06) 0%, transparent 50%),
        radial-gradient(at 80% 20%, rgba(59, 130, 246, 0.04) 0%, transparent 50%);
}

.auth-card {
    background-color: var(--bg-card);
    padding: 2.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    text-align: center;
    width: 90%;
    max-width: 400px;
}

.auth-logo {
    margin-bottom: 1rem;
}
.auth-logo img {
    border-radius: 12px;
    opacity: 0.9;
}

.auth-card h1 {
    font-weight: 700;
    font-size: 1.5rem;
    margin-bottom: 0.3rem;
    letter-spacing: -0.02em;
}
.auth-card p {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

.error-msg {
    color: var(--danger);
    margin-top: 0.8rem;
    font-size: 0.85rem;
}

/* ===== BUTTONS ===== */
button {
    cursor: pointer;
    border: none;
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all var(--transition);
    border-radius: var(--radius-sm);
}

.btn-primary {
    background-color: var(--primary);
    color: #fff;
    padding: 0.65rem 1.4rem;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
}
.btn-primary:hover {
    background-color: var(--primary-hover);
    box-shadow: 0 4px 12px var(--primary-glow);
    transform: translateY(-1px);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: 0.65rem 1.4rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    width: 100%;
    margin-top: 0.75rem;
}
.btn-ghost:hover {
    border-color: var(--border-hover);
    color: var(--text-primary);
    background: var(--bg-card-hover);
    transform: translateY(-1px);
}

.btn-danger-sm {
    background: var(--danger-soft);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
    padding: 0.4rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    margin-top: 0.5rem;
}
.btn-danger-sm:hover {
    background: rgba(239, 68, 68, 0.2);
}

.btn-icon {
    background: transparent;
    color: var(--text-secondary);
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}
.btn-icon:hover {
    background-color: var(--bg-card-hover);
    transform: translateY(-1px);
}
.btn-icon-danger:hover {
    background: var(--danger-soft);
    color: var(--danger);
}

button.danger {
    background: transparent;
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
}
button.danger:hover {
    background: var(--danger-soft);
}

/* ===== TOPBAR ===== */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1.5rem;
    height: 56px;
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

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

.topbar-logo {
    width: auto;
    height: 28px;
    border-radius: 6px;
}

.topbar-title {
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    color: var(--text-primary);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* ===== TAB NAV ===== */
.tab-nav {
    display: flex;
    gap: 0;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 0 1.5rem;
    overflow-x: auto;
    flex-shrink: 0;
}

.tab {
    background: none;
    color: var(--text-muted);
    padding: 0.85rem 1.2rem;
    font-size: 0.85rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    white-space: nowrap;
    transition: all var(--transition);
}
.tab:hover {
    color: var(--text-secondary);
    background: rgba(255,255,255,0.02);
}
.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* ===== APP CONTENT ===== */
.app-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

/* ===== VIEWS ===== */
.view {
    display: none;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    max-width: 860px;
    margin: 0 auto;
    gap: 1rem;
}
.view.active {
    display: flex;
    animation: fadeInScale 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.view-header {
    margin-bottom: 0.5rem;
}
.view-header h2 {
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

/* ===== CARDS ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-card);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 0.75rem;
}
.card-header h2 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

.card-body {
    padding: 1.5rem;
}

.transcript-card {
    padding: 1.5rem;
    white-space: pre-wrap;
    font-size: 0.95rem;
    line-height: 1.8;
    color: var(--text-primary);
    min-height: 60px;
}

/* ===== INPUTS ===== */
.input-text,
.input-textarea,
.input-date {
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.9rem;
    font-size: 0.9rem;
    font-family: 'Inter', sans-serif;
    transition: border-color var(--transition);
    outline: none;
}
.input-text:focus,
.input-textarea:focus,
.input-date:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.input-textarea {
    width: 100%;
    min-height: 180px;
    resize: vertical;
    line-height: 1.6;
}

.date-picker-inline {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.date-picker-inline label {
    color: var(--text-secondary);
    font-size: 0.85rem;
    white-space: nowrap;
}

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

/* ===== MIC ===== */
.mic-container {
    position: relative;
    margin: 2rem 0 1.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
}

.mic-button {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: var(--bg-input);
    border: 3px solid var(--border-color);
    color: var(--text-secondary);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2;
    transition: all 0.3s ease;
}
.mic-button:hover {
    border-color: var(--primary);
    color: var(--primary);
    transform: scale(1.05);
    box-shadow: 0 0 0 6px var(--primary-glow);
}
.mic-button.recording {
    border-color: var(--mic-active);
    color: var(--mic-active);
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5);
    animation: pulse 1.8s infinite;
}

@keyframes pulse {
    0%   { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    70%  { box-shadow: 0 0 0 20px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

#record-status {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

/* ===== LOADER ===== */
.loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 1.5rem;
}
.loader.hidden {
    display: none;
}
.loader p {
    color: var(--text-muted);
    font-size: 0.85rem;
}
.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 0.75rem;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===== HISTORY MEMOS ===== */
.memo-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.2rem 1.5rem;
    margin-bottom: 0.75rem;
    transition: border-color var(--transition);
}
.memo-item:hover {
    border-color: var(--border-hover);
}

.memo-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 0.8rem;
    margin-bottom: 0.8rem;
    border-bottom: 1px solid var(--border-color);
}

.memo-date {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--primary);
}

.memo-content {
    white-space: pre-wrap;
    font-size: 0.9rem;
    line-height: 1.75;
    color: var(--text-secondary);
}

.btn-edit,
.btn-delete {
    background: none;
    color: var(--text-muted);
    padding: 0.35rem 0.65rem;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
}
.btn-edit:hover {
    color: var(--primary);
    background: var(--primary-soft);
}
.btn-delete {
    color: var(--danger);
}
.btn-delete:hover {
    background: var(--danger-soft);
}

/* ===== SEARCH ===== */
.search-box {
    display: flex;
    gap: 0.75rem;
}
.search-box .input-text {
    flex: 1;
}

.modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
}
.modal:not(.hidden) {
    animation: fadeIn 0.25s ease-out forwards;
}
.modal.hidden {
    display: none;
}

.modal-content {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 700px;
    box-shadow: var(--shadow-lg);
}
.modal:not(.hidden) .modal-content {
    animation: modalPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}
.modal-content h3 {
    margin-bottom: 1rem;
    font-size: 1.1rem;
    font-weight: 600;
}
.modal-content textarea {
    width: 100%;
    height: 300px;
    background-color: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 1rem;
    font-size: 0.95rem;
    margin-bottom: 1rem;
    resize: vertical;
    font-family: 'Inter', sans-serif;
    outline: none;
}
.modal-content textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--border-hover);
}

/* ===== MOBILE ===== */
@media (max-width: 640px) {
    .topbar {
        padding: 0 1rem;
    }
    .tab-nav {
        padding: 0 0.5rem;
    }
    .tab {
        padding: 0.75rem 0.8rem;
        font-size: 0.8rem;
    }
    .tab span {
        display: none;
    }
    .tab svg {
        width: 20px;
        height: 20px;
    }
    .app-content {
        padding: 1rem;
    }
    .card-header {
        padding: 0.8rem 1rem;
    }
    .card-body {
        padding: 1rem;
    }
    .search-box {
        flex-direction: column;
    }
    .memo-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}
/* ===== MARKDOWN BODY ===== */
.markdown-body {
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text-primary);
}
.markdown-body p {
    margin-bottom: 1rem;
}
.markdown-body p:last-child {
    margin-bottom: 0;
}
.markdown-body strong {
    font-weight: 600;
    color: #fff;
    background-color: var(--primary-soft);
    padding: 0 0.2rem;
    border-radius: 4px;
}
.markdown-body em {
    font-style: italic;
    color: var(--text-secondary);
}
.markdown-body ul, .markdown-body ol {
    margin-bottom: 1rem;
    padding-left: 1.5rem;
}
.markdown-body li {
    margin-bottom: 0.25rem;
}
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 {
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    color: #fff;
    font-weight: 600;
}
.markdown-body blockquote {
    border-left: 3px solid var(--primary);
    padding-left: 1rem;
    color: var(--text-secondary);
    margin: 1rem 0;
    background: var(--bg-primary);
    padding: 0.5rem 1rem;
    border-radius: 0 4px 4px 0;
}
