:root { color-scheme: light; }

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.6;
    color: #1a1a2e;
    background: #fafafa;
}

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.05);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 40px);
}

header {
    background: white;
    border-bottom: 1px solid #eaeaea;
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1a1a2e;
    margin: 0;
}

.user-info {
    background: #f0f2f5;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
}

.user-info .label {
    color: #666;
    margin-right: 5px;
}

.user-info .value {
    color: #4a6fa5;
    font-weight: 500;
}

.action-panel {
    padding: 12px 24px;
    background: #f8f9fc;
    border-top: 1px solid #eaeaea;
    border-bottom: 1px solid #eaeaea;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.action-panel button {
    padding: 8px 16px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    color: #333;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.action-panel button:hover:not(:disabled) {
    background: #4a6fa5;
    border-color: #4a6fa5;
    color: white;
    transform: translateY(-1px);
}

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

.main-content {
    flex: 1;
    padding: 24px;
    background: #fafafa;
}

.window-panel, .form-panel {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.window-header {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid #eaeaea;
}

.window-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: #1a1a2e;
    margin-bottom: 8px;
}

.window-description {
    color: #666;
    font-size: 0.9rem;
    white-space: pre-wrap;
}

.section {
    margin-bottom: 28px;
}

.section-inline-summary {
    margin-bottom: 16px;
    line-height: 1.5;
}

.section h3 {
    color: #4a6fa5;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.section-disclosure summary {
    display: inline-block;
    cursor: pointer;
    padding: 7px 12px;
    border: 1px solid #4a6fa5;
    border-radius: 8px;
    color: #294d77;
    font-size: 0.85rem;
    list-style: none;
}
.section-disclosure summary::-webkit-details-marker { display: none; }
.section-disclosure summary::before { content: '▸ '; }
.section-disclosure[open] summary::before { content: '▾ '; }
.section-disclosure .disclosure-collapse,
.section-disclosure[open] .disclosure-expand { display: none; }
.section-disclosure[open] .disclosure-collapse { display: inline; }
.section-disclosure .section-content { margin-top: 12px; }
html[data-theme="dark"] .section-disclosure summary { color: #d4e7f6; border-color: #5486b3; }

.list-item {
    background: #f9f9f9;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    border-left: 3px solid #4a6fa5;
    transition: all 0.2s;
}

.list-item:hover {
    background: #f5f5f5;
    transform: translateX(2px);
}

.list-item-title {
    font-weight: 600;
    color: #1a1a2e;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.list-item-subtitle {
    color: #888;
    font-size: 0.85rem;
    margin-bottom: 10px;
}

.list-item-detail {
    color: #999;
    font-size: 0.8rem;
    padding-left: 12px;
    border-left: 2px solid #eaeaea;
    margin-bottom: 4px;
}

.list-item-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.list-item-actions button {
    padding: 6px 14px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 20px;
    color: #263746;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.list-item-actions button:hover {
    background: #4a6fa5;
    border-color: #4a6fa5;
    color: white;
}

.list-item-actions button.primary {
    background: #4a6fa5;
    border-color: #4a6fa5;
    color: white;
    font-weight: 600;
}

.list-item-actions button.primary:hover {
    background: #3a5a8a;
    border-color: #3a5a8a;
}

.list-item-actions button.secondary {
    background: #f7f7f7;
    color: #3f4c59;
}

.list-item-actions button.danger {
    background: #dc3545;
    border-color: #dc3545;
    color: white;
}

.window-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid #eaeaea;
}

.sequence-navigation {
    margin-top: 0;
    margin-bottom: 12px;
    padding-top: 0;
    border-top: 0;
    gap: 8px;
}

.sequence-navigation button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.sequence-follow-controls {
    margin-bottom: 24px;
}

.sequence-follow-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.sequence-follow-label input {
    margin: 0;
}

.window-actions button {
    padding: 10px 20px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.window-actions button.primary {
    background: #4a6fa5;
    border-color: #4a6fa5;
    color: white;
}

.window-actions button.primary:hover {
    background: #3a5a8a;
    transform: translateY(-1px);
}

.window-actions button.vote {
    background: #eef5fb;
    border-color: #9bbbd8;
    color: #2f587c;
}

.window-actions button.vote-selected {
    background: #d6ebdf;
    border-color: #4b966b;
    color: #195638;
    font-weight: 600;
}

.window-actions button.vote:hover:not(:disabled) { background: #dcecf8; }
.window-actions button.vote-selected:hover:not(:disabled) { background: #c4e3d1; }

.app-header-left,
.app-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.app-brand { display: flex; align-items: center; gap: 12px; }
.app-brand a { display: inline-flex; align-items: center; }
.app-brand img { width: auto; height: 42px; object-fit: contain; }
.brand-icon-dark { display: none; }
html[data-theme="dark"] .brand-icon-light { display: none; }
html[data-theme="dark"] .brand-icon-dark { display: inline; }
#welcome-language { padding: 7px 10px; border: 1px solid #d8dee5; border-radius: 7px; background: white; color: #354351; }
.theme-toggle { display: inline-grid; width: 38px; height: 38px; place-items: center; padding: 8px; border: 1px solid #d8dee5; border-radius: 50%; background: transparent; color: #354351; cursor: pointer; }
.theme-toggle svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }

.public-links {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.public-links a {
    color: #4a6fa5;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 6px 10px;
    border-radius: 999px;
    background: #eef5fb;
    border: 1px solid #d7e5f1;
}

.public-links a:hover {
    background: #dcecf8;
    color: #2f587c;
}

.window-actions button.filter {
    background: #eef5fb;
    border-color: #9bbbd8;
    color: #2f587c;
}

.window-actions button.secondary {
    background: #e8f4f1;
    border-color: #4f8c80;
    color: #145b50;
}

.window-actions button:hover:not(.primary) {
    background: #f0f0f0;
}
.window-actions button.vote:hover:not(:disabled) { background: #dcecf8; }
.window-actions button.vote-selected:hover:not(:disabled) { background: #c4e3d1; }

.window-actions button.secondary:hover:not(:disabled) {
    background: #d5ece5;
}

/* Logout confirmation styles */
.guest-logout-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(0, 0, 0, 0.55);
}

.guest-logout-modal {
    box-sizing: border-box;
    width: min(100%, 520px);
    padding: 24px;
    border-radius: 12px;
    background: #fff;
    color: #24313d;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
}

.guest-logout-modal h2 { margin: 0 0 12px; }
.guest-logout-modal p { margin: 0 0 20px; }
.guest-logout-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.guest-logout-actions button { padding: 10px; cursor: pointer; }
.guest-access-code { box-sizing: border-box; width: 100%; min-height: 5em; margin: 0 0 16px; padding: 10px; overflow-wrap: anywhere; resize: vertical; }
.guest-access-qr { display: block; width: min(256px, 100%); height: auto; margin: 0 auto 16px; }
.guest-access-qr[hidden], .guest-access-qr-error[hidden] { display: none; }

@media (max-width: 480px) {
    .guest-logout-actions { grid-template-columns: 1fr; }
}

html[data-theme="dark"] .guest-logout-modal {
    background: #202831;
    color: #e8edf1;
}
html[data-theme="dark"] .guest-access-code { background: #151d25; color: #e8edf1; border-color: #687786; }

.danger {
    background: #dc3545 !important;
    border-color: #dc3545 !important;
    color: white !important;
}

.danger:hover:not(:disabled) {
    background: #c82333 !important;
}

.danger:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#logout-confirm-username {
    user-select: none;
    -webkit-user-select: none;
}

.form-panel h3 {
    color: #4a6fa5;
    margin-bottom: 20px;
    font-size: 1.2rem;
}

html[data-theme="dark"] { color-scheme: dark; }
html[data-theme="dark"] body { color: #e8edf1; background: #151a20; }
html[data-theme="dark"] .app-container,
html[data-theme="dark"] header,
html[data-theme="dark"] .window-panel,
html[data-theme="dark"] .form-panel,
html[data-theme="dark"] .section,
html[data-theme="dark"] .list-item,
html[data-theme="dark"] .info-card { color: #e8edf1; background: #202831; border-color: #3a4651; }
html[data-theme="dark"] .app-header { border-bottom-color: #3a4651; }
html[data-theme="dark"] header h1,
html[data-theme="dark"] .window-header h2,
html[data-theme="dark"] .section h3,
html[data-theme="dark"] .form-panel h3 { color: #edf2f6; }
html[data-theme="dark"] .info-label { color: #b9c5cf; }
html[data-theme="dark"] .info-value { color: #f1f5f8; }
html[data-theme="dark"] .list-item-title { color: #f1f5f8; }
html[data-theme="dark"] .list-item-subtitle { color: #c1cbd4; }
html[data-theme="dark"] .list-item-detail { color: #aebbc6; }
html[data-theme="dark"] .main-content,
html[data-theme="dark"] .action-panel { color: #e8edf1; background: #171e25; border-color: #34404a; }
html[data-theme="dark"] .user-info,
html[data-theme="dark"] .window-actions button,
html[data-theme="dark"] .action-panel button,
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea { color: #e8edf1; background: #151a20; border-color: #53616d; }
html[data-theme="dark"] #welcome-language { color: #e8edf1; background: #151a20; border-color: #53616d; }
html[data-theme="dark"] .window-actions button.primary { background: #37658f; border-color: #5486b3; color: white; }
html[data-theme="dark"] .window-actions button.vote { background: #203c52; border-color: #5486b3; color: #d9edfc; }
html[data-theme="dark"] .window-actions button.vote-selected { background: #1d543c; border-color: #6dbf8d; color: #e6ffef; }
html[data-theme="dark"] .window-actions button.secondary { color: #d4f5ee; background: #173d39; border-color: #4eb5a3; }
html[data-theme="dark"] .window-actions button.secondary:hover:not(:disabled) { background: #23544e; }
html[data-theme="dark"] .list-item-actions button { color: #e8edf1; background: #273440; border-color: #596a78; }
html[data-theme="dark"] .list-item-actions button.primary { color: #fff; background: #37658f; border-color: #5486b3; }
html[data-theme="dark"] .list-item-actions button.secondary { color: #e8edf1; background: #303b45; border-color: #64727d; }
html[data-theme="dark"] .list-item-actions button.danger { color: #fff; background: #a92735; border-color: #e05260; }
html[data-theme="dark"] .list-item-actions button:hover:not(:disabled) { color: #fff; background: #3c5366; }
html[data-theme="dark"] .theme-toggle { color: #e8edf1; border-color: #53616d; }
html[data-theme="dark"] .public-links a { color: #d4e7f6; background: #263544; border-color: #40576c; }

.client-error {
    margin-bottom: 16px;
    padding: 12px 14px;
    border: 1px solid #dc3545;
    border-radius: 6px;
    background: #fff5f5;
    color: #a61b29;
    font-weight: 600;
}

.form-field {
    margin-bottom: 16px;
}

.form-field label {
    display: block;
    margin-bottom: 6px;
    color: #555;
    font-weight: 500;
    font-size: 0.85rem;
}

.form-field input,
.form-field select,
.form-field textarea {
    width: 100%;
    padding: 10px 12px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 0.9rem;
    transition: border 0.2s;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
    outline: none;
    border-color: #4a6fa5;
}

.duration-anchor-field > label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.form-field .duration-anchor-field input[type="radio"] {
    width: auto;
    padding: 0;
    margin: 0;
}

.duration-anchor-details:not([hidden]) {
    display: flex;
    align-items: end;
    gap: 8px;
    flex-wrap: wrap;
    margin: 8px 0 0 24px;
}

.duration-anchor-details label { margin: 0; }
.form-field .duration-anchor-count { width: 6rem; }
.form-field .duration-anchor-unit { width: auto; }

.form-field .form-help {
    display: block;
    margin-top: 8px;
    color: #555;
    line-height: 1.4;
}
html[data-theme="dark"] .form-field .form-help { color: #b9c5cf; }

.form-buttons {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    justify-content: flex-start;
}

.form-buttons button {
    padding: 10px 20px;
    border-radius: 8px;
    border: 1px solid #ddd;
    background: white;
    cursor: pointer;
}

.form-buttons button.primary {
    background: #4a6fa5;
    border-color: #4a6fa5;
    color: white;
}

.info-item {
    display: flex;
    padding: 10px 0;
    border-bottom: 1px solid #eaeaea;
}

.info-label {
    width: 140px;
    font-weight: 500;
    color: #555;
}

.info-value {
    color: #1a1a2e;
}

.ballot-option {
    padding: 10px 12px;
    background: #f9f9f9;
    margin-bottom: 8px;
    border-radius: 8px;
    border-left: 3px solid #4a6fa5;
}

.vote-composer {
    margin-top: 24px;
    padding: 20px;
    border-radius: 16px;
    background: linear-gradient(180deg, #ffffff 0%, #f6f8fc 100%);
    border: 1px solid #e5eaf2;
    box-shadow: 0 8px 24px rgba(26, 26, 46, 0.06);
}

.vote-composer-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 18px;
}

.vote-composer-header h3 {
    margin: 0 0 6px 0;
    color: #1a1a2e;
    font-size: 1.05rem;
}

.vote-composer-header p,
.vote-composer-help {
    color: #667085;
    font-size: 0.9rem;
}

.vote-composer-meta {
    padding: 8px 12px;
    border-radius: 999px;
    background: #eef3fb;
    color: #3a5a8a;
    font-weight: 600;
    white-space: nowrap;
}

.vote-selection {
    margin-bottom: 16px;
}

.vote-selection h4 {
    margin-bottom: 10px;
    font-size: 0.9rem;
    color: #4a6fa5;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.vote-selection-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.vote-empty {
    color: #8a8fa3;
    font-style: italic;
}

.vote-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid #cfd9ea;
    background: #ffffff;
    color: #1a1a2e;
    cursor: pointer;
}

.vote-chip-index {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #4a6fa5;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
}

.vote-chip-remove {
    color: #8a8fa3;
    font-weight: 700;
}

.vote-options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.vote-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid #d7e1f0;
    background: #ffffff;
    cursor: pointer;
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.vote-option:hover {
    transform: translateY(-1px);
    border-color: #4a6fa5;
    box-shadow: 0 6px 14px rgba(74, 111, 165, 0.12);
}

.vote-option.selected {
    border-color: #4a6fa5;
    background: #eef3fb;
}

.vote-option-order {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 8px;
    border-radius: 999px;
    background: #4a6fa5;
    color: white;
    font-size: 0.8rem;
    font-weight: 700;
}

.vote-composer-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.vote-composer-actions button {
    padding: 10px 16px;
    border-radius: 10px;
    border: 1px solid #d7e1f0;
    background: white;
    cursor: pointer;
}

.vote-composer-actions button.primary {
    background: #4a6fa5;
    border-color: #4a6fa5;
    color: white;
}

.vote-composer-actions button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ballot-title {
    font-weight: 600;
    margin-bottom: 12px;
    color: #1a1a2e;
}

.propose-option {
    margin-top: 12px;
    padding: 8px 16px;
    background: #4a6fa5;
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
}

.output-panel {
    background: #1e1e1e;
    border-radius: 8px;
    padding: 16px;
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    max-height: 150px;
    overflow-y: auto;
}

.output-panel h3 {
    color: #4a6fa5;
    margin-bottom: 10px;
    font-size: 0.85rem;
}

#output {
    color: #0f0;
    white-space: pre-wrap;
}

.output-panel.hidden {
    display: none;
}

.message-indicator button {
    background: #4a6fa5;
    color: white;
    padding: 6px 14px;
    border-radius: 20px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
}

.message-indicator button span {
    background: white;
    color: #4a6fa5;
    border-radius: 50%;
    padding: 2px 6px;
    font-size: 0.75rem;
}

.empty-list {
    color: #999;
    font-style: italic;
    padding: 20px;
    text-align: center;
    background: #f9f9f9;
    border-radius: 8px;
}

.items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .app-container {
        border-radius: 12px;
    }

    header {
        flex-direction: column;
        text-align: center;
    }

    .main-content {
        padding: 16px;
    }

    .window-panel, .form-panel {
        padding: 16px;
    }

    .info-label {
        width: 100px;
    }

    .items-grid {
        grid-template-columns: 1fr;
    }

    .window-actions, .list-item-actions {
        justify-content: center;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .items-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1025px) {
    .items-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}
