/* ============================================================
   Scroll — Single Stylesheet
   ============================================================ */

/* --- Design Tokens --- */
:root {
    --paper: #F5F0E8;
    --paper-future: #FAF7F0;
    --paper-shadow: rgba(0, 0, 0, 0.08);
    --accent: #4A90D9;
    --accent-hover: #3A7BC8;
    --bg: #E8E4DD;
    --text: #1A1A2E;
    --text-secondary: #666666;
    --text-muted: #999999;
    --border: #D5D0C8;
    --error: #C0392B;
    --success: #27AE60;
    --font-ui: system-ui, -apple-system, Arial, sans-serif;
    --font-notes: Georgia, 'Times New Roman', serif;
    --radius: 4px;
    --panel-speed: 280ms;
    --fade-speed: 400ms;
    --timeline-height: 56px;
}

/* --- Reset & Base --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: var(--font-ui);
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
    min-height: 100vh;
}

button {
    cursor: pointer;
    font-family: inherit;
    border: none;
    background: none;
}

input, textarea, select {
    font-family: inherit;
    font-size: 1rem;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* --- Auth Pages --- */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg);
}

.auth-card {
    background: var(--paper);
    padding: 2.5rem 2rem;
    border-radius: var(--radius);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.auth-logo {
    font-family: var(--font-notes);
    font-size: 2.5rem;
    font-weight: normal;
    color: var(--text);
    margin-bottom: 0.25rem;
}

.auth-tagline {
    color: var(--text-secondary);
    font-style: italic;
    margin-bottom: 1.5rem;
}

.auth-error {
    background: #FDE8E8;
    color: var(--error);
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.auth-card form {
    text-align: left;
}

.auth-card label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
    margin-top: 1rem;
}

.auth-card label:first-of-type {
    margin-top: 0;
}

.auth-card input[type="text"],
.auth-card input[type="email"],
.auth-card input[type="password"] {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.auth-card input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(74, 144, 217, 0.2);
}

.auth-card .btn-primary {
    width: 100%;
    margin-top: 1.5rem;
}

.auth-link {
    margin-top: 1.25rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* --- About Page --- */
.about-card {
    background: var(--paper);
    padding: 2.5rem 2rem;
    border-radius: var(--radius);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 560px;
    text-align: center;
}

.about-body {
    text-align: left;
    font-family: var(--font-notes);
    font-size: 1.05rem;
    line-height: 1.8;
    color: var(--text);
    margin-top: 1.5rem;
}

.about-body p {
    margin-bottom: 1.1rem;
}

.about-body p:last-of-type {
    margin-bottom: 0;
}

.about-sign-off {
    font-style: italic;
    color: var(--text-secondary);
    margin-top: 0.5rem;
    text-align: center;
}

.about-back {
    display: inline-block;
    margin-top: 1.75rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.about-back:hover {
    color: var(--accent);
}

/* --- Buttons --- */
.btn-primary {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    padding: 0.65rem 1.5rem;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    border: none;
    transition: background 0.2s;
}

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

.btn-sm {
    font-size: 0.8rem;
    padding: 0.3rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    color: var(--text-secondary);
    transition: background 0.2s;
}

.btn-sm:hover {
    background: var(--bg);
}

.btn-icon {
    font-size: 1.1rem;
    padding: 0.25rem;
    color: var(--text-secondary);
    transition: color 0.2s;
    position: relative;
}

.btn-icon:hover {
    color: var(--text);
}

/* --- Timeline Navigator --- */
#timeline-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--timeline-height);
    background: var(--paper);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 4px var(--paper-shadow);
    z-index: 100;
    display: flex;
    align-items: center;
    padding: 0 1rem;
    gap: 1rem;
}

#timeline-breadcrumb {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    min-width: 140px;
}

#timeline-scrubber {
    flex: 1;
    padding: 0 0.5rem;
}

#scrubber-track {
    position: relative;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    cursor: pointer;
}

#scrubber-thumb {
    position: absolute;
    top: -5px;
    left: 50%;
    width: 16px;
    height: 16px;
    background: var(--accent);
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transform: translateX(-50%);
    cursor: grab;
    transition: left 0.15s ease-out;
}

#scrubber-thumb:active {
    cursor: grabbing;
    transform: translateX(-50%) scale(1.15);
}

#timeline-buttons {
    display: flex;
    gap: 0.4rem;
}

#timeline-buttons button {
    font-size: 0.8rem;
    padding: 0.35rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    color: var(--text-secondary);
    white-space: nowrap;
    transition: background 0.2s, color 0.2s;
}

#timeline-buttons button:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

#btn-meeting-panel {
    font-size: 1.3rem;
    padding: 0.25rem 0.5rem;
    color: var(--text-secondary);
}

#btn-meeting-panel:hover {
    color: var(--accent);
}

/* --- User Avatar Button (Timeline) --- */
#btn-profile {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    letter-spacing: 0.5px;
    transition: background 0.2s;
}

#btn-profile:hover {
    background: var(--accent-hover);
}

/* --- Profile Panel --- */
#profile-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 420px;
    max-width: 100vw;
    background: var(--paper);
    box-shadow: -4px 0 16px rgba(0, 0, 0, 0.12);
    z-index: 200;
    overflow-y: auto;
    transition: transform var(--panel-speed) ease-out;
}

#profile-panel.panel-closed {
    transform: translateX(100%);
}

#profile-panel.panel-open {
    transform: translateX(0);
}

.profile-avatar-large {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 1.5rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.25rem;
    letter-spacing: 1px;
}

.profile-info {
    margin-bottom: 1rem;
}

.profile-field {
    padding: 0.6rem 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.profile-field:last-child {
    border-bottom: none;
}

.profile-field label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.15rem;
}

.profile-value {
    font-size: 0.95rem;
    color: var(--text);
}

.profile-role {
    text-transform: capitalize;
}

.profile-editable {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.profile-section-divider {
    height: 1px;
    background: var(--border);
    margin: 1.25rem 0;
}

.profile-form-section {
    margin-top: 0.75rem;
}

.profile-form-section h3 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
}

.profile-form-section label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
    margin-top: 0.75rem;
}

.profile-form-section label:first-of-type {
    margin-top: 0;
}

.profile-form-section input[type="text"],
.profile-form-section input[type="password"] {
    width: 100%;
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    font-size: 0.95rem;
}

.profile-form-section input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(74, 144, 217, 0.2);
}

.profile-message {
    font-size: 0.85rem;
    margin-top: 0.5rem;
    min-height: 1.2em;
}

.profile-message.error {
    color: var(--error);
}

.profile-message.success {
    color: var(--success);
}

.btn-logout {
    width: 100%;
    padding: 0.65rem 1.5rem;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    border: 1px solid var(--error);
    background: #fff;
    color: var(--error);
    transition: background 0.2s, color 0.2s;
}

.btn-logout:hover {
    background: var(--error);
    color: #fff;
}

/* --- Paper Roll --- */
#paper-roll {
    max-width: 800px;
    margin: 0 auto;
    margin-top: calc(var(--timeline-height) + 1rem);
    margin-bottom: 2rem;
    background: var(--paper);
    box-shadow: -4px 0 8px var(--paper-shadow), 4px 0 8px var(--paper-shadow);
    min-height: calc(100vh - var(--timeline-height) - 3rem);
    padding: 0;
}

.scroll-sentinel {
    height: 1px;
    width: 100%;
}

/* --- Meeting Section --- */
.meeting {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border);
    position: relative;
}

.meeting:last-of-type {
    border-bottom: none;
}

.meeting-future {
    background: var(--paper-future);
}

.meeting-deleted {
    opacity: 0.6;
}

.meeting-deleted-banner {
    background: #F0E6E6;
    color: var(--error);
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
}

/* --- Meeting Header --- */
.meeting-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
    position: sticky;
    top: var(--timeline-height);
    background: inherit;
    padding: 0.5rem 0;
    z-index: 10;
}

.meeting-header-left {
    flex: 1;
    min-width: 0;
}

.meeting-title {
    font-family: var(--font-notes);
    font-size: 1.4rem;
    font-weight: normal;
    color: var(--text);
    cursor: text;
    outline: none;
    padding: 0.1rem 0.25rem;
    margin: 0 -0.25rem;
    border-radius: 2px;
    transition: background 0.2s;
}

.meeting-title:hover {
    background: rgba(0, 0, 0, 0.03);
}

.meeting-title[contenteditable="true"] {
    background: #fff;
    box-shadow: 0 0 0 2px rgba(74, 144, 217, 0.3);
}

.meeting-datetime {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.15rem;
}

.meeting-header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
    padding-top: 0.25rem;
}

.badge {
    position: absolute;
    top: -4px;
    right: -6px;
    background: var(--accent);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 1px 4px;
    border-radius: 8px;
    line-height: 1.2;
}

.save-indicator {
    font-size: 0.75rem;
    color: var(--success);
    font-weight: 600;
    opacity: 0;
    transition: opacity var(--fade-speed);
    white-space: nowrap;
}

.save-indicator.visible {
    opacity: 1;
}

.save-indicator.error {
    color: var(--error);
}

/* --- Notes Area --- */
.meeting-notes {
    font-family: var(--font-notes);
    font-size: 1rem;
    line-height: 1.7;
    color: var(--text);
    min-height: 120px;
    padding: 0.75rem;
    border-left: 2px solid #E0D8CC;
    outline: none;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.meeting-notes:focus {
    border-left-color: var(--accent);
}

.meeting-notes:empty::before {
    content: 'Start typing your notes...';
    color: var(--text-muted);
    font-style: italic;
    pointer-events: none;
}

.meeting-notes h1,
.meeting-notes h2,
.meeting-notes h3 {
    font-family: var(--font-notes);
    color: var(--text);
    margin: 0.5em 0 0.25em;
    line-height: 1.3;
}

.meeting-notes h1 { font-size: 1.5rem; }
.meeting-notes h2 { font-size: 1.25rem; }
.meeting-notes h3 { font-size: 1.1rem; }

.meeting-notes ul,
.meeting-notes ol {
    margin: 0.25em 0;
    padding-left: 1.5em;
}

.meeting-notes li {
    line-height: 1.7;
    margin-bottom: 0.15em;
}

/* --- Shared Notes --- */
.shared-notes {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px dashed var(--border);
}

.shared-note {
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: rgba(74, 144, 217, 0.05);
    border-radius: var(--radius);
    border-left: 2px solid var(--accent);
}

.shared-note-header {
    margin-bottom: 0.5rem;
}

.shared-note-author {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent);
}

.shared-note-content {
    font-family: var(--font-notes);
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text);
}

/* --- Attachment Tray --- */
.attachment-tray {
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.02);
    border-radius: var(--radius);
    border: 1px dashed var(--border);
}

.attachment-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    margin: 0.25rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.85rem;
    max-width: 100%;
}

.attachment-thumb {
    max-height: 120px;
    max-width: 200px;
    border-radius: var(--radius);
    display: block;
    margin-bottom: 0.25rem;
}

.attachment-info {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    min-width: 0;
}

.attachment-info:hover .attachment-name {
    color: var(--accent);
}

.attachment-icon {
    flex-shrink: 0;
}

.attachment-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: color 0.2s;
}

.attachment-size {
    color: var(--text-muted);
    font-size: 0.75rem;
    flex-shrink: 0;
}

.attachment-delete {
    font-size: 1.1rem;
    color: var(--text-muted);
    flex-shrink: 0;
    padding: 0 0.15rem;
}

.attachment-delete:hover {
    color: var(--error);
}

/* --- Upload Zone --- */
.upload-zone {
    margin-top: 0.75rem;
}

.drop-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.drop-area:hover,
.drop-area.drag-over {
    border-color: var(--accent);
    background: rgba(74, 144, 217, 0.05);
}

.upload-progress {
    margin-top: 0.5rem;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.upload-progress-bar {
    height: 100%;
    background: var(--accent);
    width: 0;
    transition: width 0.2s ease-out;
    border-radius: 3px;
}

/* --- Meeting Manager Panel --- */
#meeting-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 420px;
    max-width: 100vw;
    background: var(--paper);
    box-shadow: -4px 0 16px rgba(0, 0, 0, 0.12);
    z-index: 200;
    overflow-y: auto;
    transition: transform var(--panel-speed) ease-out;
}

#meeting-panel.panel-closed {
    transform: translateX(100%);
}

#meeting-panel.panel-open {
    transform: translateX(0);
}

.panel-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 199;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--panel-speed);
}

.panel-backdrop.visible {
    opacity: 1;
    pointer-events: auto;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.panel-header h2 {
    font-family: var(--font-notes);
    font-size: 1.3rem;
    font-weight: normal;
}

.panel-close {
    font-size: 1.5rem;
    color: var(--text-secondary);
}

.panel-close:hover {
    color: var(--text);
}

.panel-content {
    padding: 1.25rem 1.5rem;
}

.panel-content .btn-new-meeting {
    width: 100%;
    margin-bottom: 1rem;
}

/* --- Panel Form --- */
.panel-form {
    margin-bottom: 1rem;
}

.meeting-form {
    background: rgba(0, 0, 0, 0.02);
    padding: 1.25rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.meeting-form h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
}

.meeting-form label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
    margin-top: 0.75rem;
}

.meeting-form label:first-of-type {
    margin-top: 0;
}

.required {
    color: var(--error);
}

.meeting-form input[type="text"],
.meeting-form input[type="date"],
.meeting-form input[type="time"],
.meeting-form textarea {
    width: 100%;
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    font-size: 0.95rem;
}

.meeting-form input:focus,
.meeting-form textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(74, 144, 217, 0.2);
}

.meeting-form textarea {
    resize: vertical;
    font-family: var(--font-ui);
}

.form-buttons {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.form-buttons .btn-primary {
    flex: 1;
    padding: 0.5rem;
    font-size: 0.9rem;
}

.btn-cancel {
    flex: 1;
    padding: 0.5rem;
    font-size: 0.9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    color: var(--text-secondary);
}

.btn-cancel:hover {
    background: var(--bg);
}

/* --- Panel Search --- */
.panel-search {
    margin-bottom: 1rem;
}

.search-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    font-size: 0.9rem;
}

.search-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(74, 144, 217, 0.2);
}

/* --- Panel Meeting List --- */
.panel-meetings-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.panel-meeting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.65rem 0.75rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.panel-meeting-row.row-deleted {
    opacity: 0.5;
    text-decoration: line-through;
}

.row-info {
    min-width: 0;
    flex: 1;
}

.row-title {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.row-date {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.row-actions {
    display: flex;
    gap: 0.35rem;
    flex-shrink: 0;
    margin-left: 0.5rem;
}

.panel-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem 0;
    font-style: italic;
}

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-secondary);
}

.empty-title {
    font-family: var(--font-notes);
    font-size: 1.5rem;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.empty-subtitle {
    font-size: 0.95rem;
    color: var(--text-muted);
}

/* --- Responsive --- */
@media (max-width: 860px) {
    #paper-roll {
        margin-left: 0.5rem;
        margin-right: 0.5rem;
    }

    .meeting {
        padding: 1.25rem 1.25rem;
    }
}

@media (max-width: 600px) {
    #timeline-nav {
        flex-wrap: wrap;
        height: auto;
        padding: 0.5rem;
        gap: 0.5rem;
    }

    :root {
        --timeline-height: 90px;
    }

    #timeline-breadcrumb {
        min-width: auto;
        order: 1;
    }

    #timeline-scrubber {
        order: 3;
        width: 100%;
        flex: none;
    }

    #timeline-buttons {
        order: 2;
        margin-left: auto;
    }

    #btn-meeting-panel {
        order: 2;
    }

    #paper-roll {
        margin-left: 0;
        margin-right: 0;
        box-shadow: none;
    }

    .meeting {
        padding: 1rem;
    }

    .meeting-header {
        flex-direction: column;
        gap: 0.5rem;
    }

    .meeting-header-right {
        align-self: flex-end;
    }

    #meeting-panel,
    #profile-panel {
        width: 100vw;
    }

    #btn-profile {
        order: 2;
    }

    .meeting-title {
        font-size: 1.2rem;
    }
}
