/* Global Styles */
:root {
    --bg:                oklch(96% 0.008 80);
    --surface:           oklch(92% 0.010 80);
    --text-primary:      oklch(22% 0.012 60);
    --text-secondary:    oklch(45% 0.014 60);
    --text-tertiary:     oklch(62% 0.010 60);
    --accent:            oklch(46% 0.10 140);
    --accent-mid:        oklch(62% 0.09 140);
    --accent-light:      oklch(88% 0.05 140);
    --accent-warm:       oklch(78% 0.12 75);
    --accent-warm-light: oklch(93% 0.06 75);
    --border:            oklch(22% 0.012 60 / 0.12);
    --text-on-accent:    oklch(99% 0.008 140);

    --font-heading: Georgia, 'Times New Roman', serif;
    --font-body:    -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

body {
    font-family: var(--font-body);
    font-size: 18px;
    background: var(--bg);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* Container */
.container {
    background: var(--surface);
    border-radius: 20px;
    padding: 50px 40px;
    max-width: 500px;
    width: 100%;
    box-shadow: 0 4px 24px oklch(22% 0.012 60 / 0.10);
}

/* Headers */
.header {
    text-align: center;
    margin-bottom: 40px;
}

.icon {
    font-size: 64px;
    margin-bottom: 20px;
}

h1 {
    font-family: var(--font-heading);
    color: var(--text-primary);
    font-size: 32px;
    margin-bottom: 10px;
    font-weight: 700;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 18px;
    line-height: 1.6;
}

/* Buttons - Base Styles */
button {
    font-family: var(--font-body);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 2px 8px oklch(22% 0.012 60 / 0.10);
}

button:hover {
    transform: translateY(-2px);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Primary Button */
.btn-primary {
    background: var(--accent);
    color: var(--text-on-accent);
    padding: 18px 40px;
    font-size: 18px;
}

.btn-primary:hover {
    background: oklch(38% 0.09 140);
    box-shadow: 0 6px 20px oklch(46% 0.10 140 / 0.35);
}

/* Secondary Button */
.btn-secondary {
    background: var(--bg);
    color: var(--accent);
    border: 2px solid var(--accent);
    padding: 18px 40px;
    font-size: 18px;
}

/* Small Button */
.btn-small {
    padding: 12px 24px;
    font-size: 16px;
    border-radius: 12px;
    min-height: 48px;
}

/* Gray Button */
.btn-gray {
    background: var(--text-secondary);
    color: var(--text-on-accent);
}

.btn-gray:hover {
    background: var(--text-primary);
}

/* Status/Message Box */
#status {
    margin-top: 30px;
    padding: 20px;
    background: var(--bg);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 18px;
    line-height: 1.8;
    min-height: 60px;
    border: 1px solid var(--border);
}

#status:empty {
    display: none;
}

/* Footer */
.footer {
    text-align: center;
    margin-top: 30px;
    color: var(--text-tertiary);
    font-size: 16px;
}

/* Form Inputs */
input, textarea {
    width: 100%;
    padding: 15px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 18px;
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text-primary);
    transition: border-color 0.2s;
}

input:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
}

/* Loading State */
.loading {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

/* Message Styles */
.message {
    margin-top: 20px;
    padding: 15px;
    border-radius: 10px;
    font-size: 16px;
    text-align: center;
}

.message.error {
    background: #fde8e8;
    color: #9b2c2c;
}

.message.success {
    background: var(--accent-warm-light);
    color: oklch(52% 0.14 75);
}

.message.info {
    background: #e8f0fe;
    color: #2c4a8c;
}

/* Recording Area */
.recording-area {
    text-align: center;
    margin: 40px 0;
}

#recordButton {
    background: var(--accent);
    color: var(--text-on-accent);
    font-size: 18px;
    padding: 20px 50px;
}

#stopButton {
    background: oklch(48% 0.18 25);
    color: var(--text-on-accent);
    font-size: 18px;
    padding: 20px 50px;
    display: none;
}

#stopButton:hover {
    box-shadow: 0 6px 20px oklch(48% 0.18 25 / 0.35);
}

/* Header language switcher */
.header-lang {
    margin-top: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.header-lang label {
    color: var(--text-secondary);
    font-size: 15px;
}

/* Live recording indicator */
.recording-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    color: oklch(48% 0.18 25);
    font-weight: 600;
    justify-content: center;
    margin-bottom: 4px;
}

.recording-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: oklch(48% 0.18 25);
    animation: pulse-dot 1.2s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: 0.35; transform: scale(0.75); }
}

/* Error recovery */
.error-recovery {
    text-align: center;
}

.error-recovery p {
    color: oklch(40% 0.14 25);
    margin-bottom: 16px;
    font-size: 17px;
    line-height: 1.5;
}

.retry-btn {
    background: var(--accent);
    color: var(--text-on-accent);
    padding: 14px 36px;
    font-size: 17px;
    font-weight: 600;
    font-family: var(--font-body);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    min-height: 48px;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 2px 8px oklch(22% 0.012 60 / 0.10);
}

.retry-btn:hover {
    background: oklch(38% 0.09 140);
    box-shadow: 0 6px 20px oklch(46% 0.10 140 / 0.35);
    transform: translateY(-2px);
}

/* Toast notification */
.toast {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(-16px);
    background: oklch(22% 0.012 60);
    color: oklch(97% 0.006 80);
    padding: 14px 28px;
    border-radius: 12px;
    font-family: var(--font-body);
    font-size: 16px;
    font-weight: 500;
    box-shadow: 0 8px 32px oklch(22% 0.012 60 / 0.28);
    opacity: 0;
    transition: opacity 0.2s ease-out, transform 0.2s ease-out;
    pointer-events: none;
    z-index: 9999;
    white-space: nowrap;
}
.toast.toast-success::before {
    content: '✓ ';
    color: oklch(72% 0.14 140);
}
.toast.toast-error::before {
    content: '⚠ ';
    color: oklch(72% 0.18 30);
}
.toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Page-Specific: Index.html - Question Section */
#questionSection button {
    width: 100%;
    padding: 20px;
    margin-bottom: 10px;
    font-size: 18px;
}

/* Page-Specific: Completion Buttons */
#completionButtons button {
    width: 100%;
    padding: 18px;
    font-size: 18px;
    margin-bottom: 15px;
}

/* Page-Specific: Current Question Display */
#currentQuestionDisplay {
    margin-bottom: 20px;
    padding: 20px;
    background: var(--bg);
    border-radius: 10px;
    font-size: 18px;
    color: var(--text-primary);
    border: 1px solid var(--border);
}

/* Page-Specific: Question Section Box */
#questionSection {
    margin-bottom: 30px;
    padding: 25px;
    background: var(--bg);
    border-radius: 12px;
    border: 1px solid var(--border);
}

#suggestedQuestion {
    font-size: 18px;
    color: var(--text-primary);
    margin-bottom: 20px;
    font-weight: 500;
}

#todaysQuestionLabel {
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 14px;
    letter-spacing: -0.01em;
}

#recordQuestionBtn,
#selectQuestionBtn,
#freeRecordStartBtn {
    background: var(--accent);
    color: var(--text-on-accent);
}

#browseQuestionsBtn {
    background: var(--bg);
    color: var(--accent);
    border: 2px solid var(--accent);
}

#freeRecordBtn {
    background: var(--bg);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

#userInfo {
    margin-bottom: 15px;
    color: var(--text-secondary);
    font-size: 16px;
}

#languageLabel {
    color: var(--text-secondary);
    font-size: 15px;
    margin-right: 10px;
}

#languageSelector {
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
    background: var(--bg);
    color: var(--text-primary);
    font-family: var(--font-body);
    min-height: 48px;
}

#logoutBtn {
    background: transparent;
    color: var(--text-tertiary);
    border: 1px solid var(--border);
    padding: 10px 30px;
    font-size: 16px;
    box-shadow: none;
    min-height: 48px;
}

/* Page-Specific: login.html */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
}

#phoneHint {
    display: block;
    margin-top: 5px;
    color: var(--text-tertiary);
    font-size: 14px;
}

#sendCodeBtn,
#verifyCodeBtn {
    width: 100%;
    background: var(--accent);
    color: var(--text-on-accent);
    padding: 16px;
    font-size: 18px;
    margin-top: 10px;
    border-radius: 12px;
    min-height: 48px;
}

#sendCodeBtn:hover,
#verifyCodeBtn:hover {
    background: oklch(38% 0.09 140);
    box-shadow: 0 6px 20px oklch(46% 0.10 140 / 0.35);
}

#verificationSection {
    display: none;
}

#recaptcha-container {
    margin: 20px 0;
    display: flex;
    justify-content: center;
}

.login-language-wrap {
    margin-top: 25px;
    text-align: center;
}

/* Page-Specific: archive.html */
body.page-archive {
    display: block;
}

.archive-container {
    max-width: 900px;
    padding: 40px;
    margin: 0 auto;
}

.archive-container .header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: left;
    margin-bottom: 30px;
}

.archive-container .header .back-button {
    width: auto;
    padding: 8px 16px;
    margin-top: 0;
    font-size: 16px;
    min-height: 48px;
}

.recording-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
}

.recording-titles {
    flex: 1;
}

.recording-title-ko {
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 5px;
}

.recording-card:hover .recording-title-ko {
    color: var(--text-on-accent);
}

.recording-title-en {
    font-size: 16px;
    color: var(--text-secondary);
    font-style: italic;
}

.recording-card:hover .recording-title-en {
    color: oklch(99% 0.008 140 / 0.75);
}

.recording-category {
    display: inline-block;
    padding: 4px 12px;
    background: var(--accent-light);
    color: var(--accent);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.recording-card:hover .recording-category {
    background: oklch(99% 0.008 140 / 0.20);
    color: var(--text-on-accent);
}

#recordingsList {
    display: grid;
    gap: 16px;
}

/* Page-Specific: recording-detail.html */
body.page-detail {
    display: block;
}

.detail-container {
    max-width: 900px;
    padding: 40px;
    margin: 0 auto;
}

.detail-container .header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: left;
    margin-bottom: 30px;
}

.detail-container .header .back-button {
    width: auto;
    padding: 8px 16px;
    margin-top: 0;
    font-size: 16px;
    min-height: 48px;
}

.action-buttons {
    display: flex;
    gap: 10px;
}

.edit-button,
.save-button,
.cancel-button,
.history-button {
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    font-family: var(--font-body);
    min-height: 48px;
}

.edit-button {
    background: var(--accent-light);
    color: var(--accent);
    border: none;
}

.edit-button:hover {
    background: var(--accent);
    color: var(--text-on-accent);
}

.save-button {
    background: var(--accent);
    color: var(--text-on-accent);
    border: none;
    display: none;
}

.save-button:hover {
    background: oklch(38% 0.09 140);
}

.cancel-button,
.history-button {
    background: var(--surface);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.cancel-button {
    display: none;
}

.cancel-button:hover,
.history-button:hover {
    background: var(--bg);
    color: var(--text-primary);
}

.meta-info {
    display: flex;
    gap: 20px;
    align-items: center;
    padding: 15px 20px;
    background: var(--bg);
    border-radius: 10px;
    margin-bottom: 25px;
    font-size: 16px;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.section {
    margin-bottom: 25px;
}

.section-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.editable-field {
    width: 100%;
    padding: 15px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 18px;
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text-primary);
    line-height: 1.8;
    resize: vertical;
}

.editable-field:disabled {
    background: var(--bg);
    border-color: var(--border);
    cursor: default;
    color: var(--text-primary);
}

.editable-field:focus:not(:disabled) {
    outline: none;
    border-color: var(--accent);
}

.title-input {
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 600;
    min-height: 50px;
}

.transcription-textarea {
    min-height: 200px;
}

.audio-player {
    width: 100%;
    margin-top: 10px;
}

.version-info {
    font-size: 14px;
    color: var(--text-tertiary);
    margin-top: 8px;
    margin-bottom: 20px;
    font-style: italic;
}

.question-callout {
    margin-bottom: 20px;
    padding: 15px;
    background: var(--accent-light);
    border: 1px solid oklch(62% 0.09 140 / 0.40);
    border-radius: 8px;
}

.question-callout-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 6px;
}

.question-callout-text {
    font-size: 18px;
    color: var(--text-primary);
}

/* Page-Specific: Archive.html */
.archive-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.filters {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 15px;
}

.filter-btn {
    padding: 0 12px;
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    box-shadow: none;
    color: var(--text-tertiary);
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
}

.filter-btn.active {
    color: var(--text-primary);
    border-bottom-color: var(--accent);
}

.filter-btn:hover {
    color: var(--text-primary);
    transform: none;
}

.search-box {
    width: 100%;
    padding: 12px 20px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 18px;
    margin-bottom: 20px;
}

.recordings-grid {
    display: grid;
    gap: 16px;
}

.recording-card {
    background: var(--bg);
    padding: 20px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid var(--border);
    box-shadow: none;
}

.recording-card:hover {
    background: var(--accent);
    color: var(--text-on-accent);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px oklch(46% 0.10 140 / 0.25);
    border-color: transparent;
}

.recording-title {
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
}

.recording-meta {
    display: flex;
    gap: 15px;
    font-size: 15px;
    color: var(--text-tertiary);
    margin-bottom: 12px;
}

.recording-card:hover .recording-meta {
    color: oklch(99% 0.008 140 / 0.75);
}

.recording-snippet {
    font-size: 16px;
    color: var(--text-secondary);
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.recording-card:hover .recording-snippet {
    color: oklch(99% 0.008 140 / 0.90);
}

.category-tag {
    display: inline-block;
    padding: 4px 12px;
    background: var(--accent-light);
    color: var(--accent);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin-top: 10px;
}

.back-button {
    margin-top: 30px;
    padding: 15px 30px;
    background: var(--text-secondary);
    color: var(--text-on-accent);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 18px;
    font-weight: 600;
    width: 100%;
    min-height: 48px;
}

.back-button:hover {
    background: var(--text-primary);
}

/* Page-Specific: questions.html */
body.page-questions {
    display: block;
}

.questions-container {
    max-width: 720px;
    padding: 40px;
    margin: 0 auto;
}

.questions-container .header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    text-align: left;
    margin-bottom: 40px;
}

.questions-container .header .back-button {
    width: auto;
    padding: 8px 16px;
    margin-top: 6px;
    font-size: 16px;
    min-height: 48px;
    flex-shrink: 0;
}

.question-category {
    margin-bottom: 36px;
}

.question-category-title {
    font-family: var(--font-heading);
    font-size: 15px;
    font-weight: 600;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.question-item {
    padding: 16px 20px;
    margin-bottom: 8px;
    background: var(--bg);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--border);
    font-size: 18px;
    color: var(--text-primary);
    min-height: 60px;
    user-select: none;
}

.question-item:hover {
    background: var(--accent);
    color: var(--text-on-accent);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px oklch(46% 0.10 140 / 0.22);
    border-color: transparent;
}

.question-item:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.question-item.answered {
    background: var(--accent-light);
    border-color: oklch(62% 0.09 140 / 0.30);
}

.question-item.answered:hover {
    background: var(--accent);
    border-color: transparent;
}

.question-text {
    flex: 1;
    line-height: 1.5;
}

.question-status {
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 8px;
    background: oklch(99% 0.008 140 / 0.65);
    color: var(--accent);
    font-weight: 600;
    margin-left: 12px;
    flex-shrink: 0;
}

.question-item.answered:hover .question-status {
    background: oklch(99% 0.008 140 / 0.20);
    color: var(--text-on-accent);
}

/* Page-Specific: version-history.html */
body.page-versions {
    display: block;
}

.versions-container {
    max-width: 900px;
    padding: 40px;
    margin: 0 auto;
}

.versions-container .header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: left;
    margin-bottom: 30px;
}

.versions-container .header .back-button {
    width: auto;
    padding: 8px 16px;
    margin-top: 0;
    font-size: 16px;
    min-height: 48px;
}

.current-version {
    background: var(--accent-light);
    border: 1px solid oklch(62% 0.09 140 / 0.40);
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 30px;
}

.version-badge {
    display: inline-block;
    background: oklch(99% 0.008 140 / 0.65);
    color: var(--accent);
    padding: 4px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin-bottom: 15px;
}

.versions-section-title {
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 20px;
    margin-top: 10px;
}

.version-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 16px;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.version-card:hover {
    border-color: oklch(62% 0.09 140 / 0.35);
    box-shadow: 0 2px 12px oklch(46% 0.10 140 / 0.08);
}

.version-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border);
    gap: 16px;
}

.version-meta {
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.version-meta strong {
    color: var(--text-primary);
    font-weight: 600;
}

.restore-btn {
    padding: 8px 16px;
    background: var(--accent);
    color: var(--text-on-accent);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font-body);
    min-height: 40px;
    flex-shrink: 0;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: none;
}

.restore-btn:hover {
    background: oklch(38% 0.09 140);
    box-shadow: 0 4px 12px oklch(46% 0.10 140 / 0.25);
    transform: translateY(-1px);
}

.restore-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.field-section {
    margin-bottom: 20px;
}

.field-section:last-child {
    margin-bottom: 0;
}

.field-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 8px;
}

.field-content {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 12px 16px;
    border-radius: 8px;
    color: var(--text-primary);
    line-height: 1.7;
    white-space: pre-wrap;
    font-size: 15px;
    max-height: 160px;
    overflow-y: auto;
    font-family: var(--font-body);
}

.field-content.changed {
    background: var(--accent-warm-light);
    border-color: oklch(78% 0.12 75 / 0.40);
}
