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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #0e0e0e;
    color: #e0e0e0;
    min-height: 100vh;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 1.5rem;
    border-bottom: 1px solid #252525;
}

header h1 {
    font-size: 1rem;
    margin: 0;
    border: 1px solid #262626;
    border-radius: 6px;
    background: #141414;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.header-brand-link {
    display: block;
    color: #d4c87a;
    text-decoration: none;
    padding: 0.35rem 0.8rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    font-size: 1rem;
}

.header-user {
    font-size: 0.8rem;
    color: #555;
}

#user-info {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.container {
    max-width: 400px;
    margin: 4rem auto;
    padding: 2rem;
}

h1 { text-align: center; margin-bottom: 2rem; }
h2 { margin-bottom: 1.5rem; font-size: 1.1rem; color: #aaa; }

input[type="text"],
input[type="password"] {
    width: 100%;
    padding: 0.7rem 1rem;
    margin-bottom: 0.8rem;
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 4px;
    color: #e0e0e0;
    font-size: 0.95rem;
}

input:focus {
    outline: none;
    border-color: #555;
}

button {
    width: 100%;
    padding: 0.7rem;
    background: #222;
    color: #e0e0e0;
    border: 1px solid #333;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.95rem;
    margin-top: 0.5rem;
}

button:hover { background: #2a2a2a; border-color: #444; }

#logout-btn {
    width: auto;
    padding: 0.3rem 0.7rem;
    font-size: 0.75rem;
    margin-top: 0;
    background: #141414;
    border: 1px solid #2a2222;
    border-radius: 6px;
    color: #a66;
}

#logout-btn:hover {
    color: #c88;
    background: #1c1818;
    border-color: #3a2a2a;
}

.error {
    color: #e55;
    font-size: 0.85rem;
    margin-top: 0.5rem;
    min-height: 1.2em;
}

.switch-text {
    margin-top: 1.5rem;
    font-size: 0.85rem;
    color: #777;
    text-align: center;
}

.switch-text a { color: #aaa; }
.switch-text a:hover { color: #e0e0e0; }

/* Account page */
.section { margin-bottom: 2.5rem; }
h3 { font-size: 0.95rem; color: #888; margin-bottom: 1rem; border-bottom: 1px solid #222; padding-bottom: 0.5rem; }

.field-row {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 0.8rem;
}
.field-row label { font-size: 0.85rem; color: #777; min-width: 100px; }
.field-row input { flex: 1; margin-bottom: 0; }
.field-value { font-size: 0.95rem; color: #ccc; }

.btn-small { width: auto; padding: 0.5rem 1rem; font-size: 0.85rem; margin-top: 0; }

.tags-list { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.tag {
    border-radius: 3px;
    padding: 0.25rem 0.6rem;
    font-size: 0.8rem;
    /* Colors applied dynamically from tag registry */
    background: #1a1a1a;
    border: 1px solid #333;
    color: #aaa;
}

/* Nav group (framed button bar in header) */
.nav-group {
    display: flex;
    align-items: stretch;
    border: 1px solid #262626;
    border-radius: 6px;
    background: #141414;
}

.nav-item {
    color: #888;
    text-decoration: none;
    font-size: 0.78rem;
    padding: 0.3rem 0.85rem;
    letter-spacing: 0.02em;
    transition: color 0.15s, background 0.15s;
}

.nav-item:hover {
    color: #ddd;
    background: #1c1c1c;
}

.nav-sep {
    width: 1px;
    background: #262626;
}

.msg { font-size: 0.85rem; margin-top: 0.5rem; min-height: 1.2em; }
.msg-ok { color: #5a5; }
.msg-err { color: #e55; }

/* ==================== LIFEBOARD ==================== */

.lb-container {
    max-width: 600px;
    margin: 1.5rem auto;
    padding: 0 1.5rem;
}

.lb-empty-state {
    text-align: center;
    padding: 3rem 0;
    color: #666;
}

/* Outer board panel frame */
.lb-board-panel {
    background: #111;
    border: 1px solid #222;
    border-radius: 8px;
    padding: 1rem;
}

/* Board selector bar */
.lb-board-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.8rem;
    background: #131313;
    border: 1px solid #222;
    border-radius: 6px;
    padding: 0.6rem 0.8rem;
}

.lb-board-select {
    flex: 1;
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 4px;
    color: #e0e0e0;
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
    appearance: auto;
}

.btn-icon {
    font-size: 1rem;
    padding: 0.3rem 0.6rem;
    line-height: 1;
}

/* Permission badges */
.perm-badge {
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}
.perm-owner { background: #2a1a2a; color: #a6a; border: 1px solid #3a2a3a; }
.perm-admin { background: #2a2a1a; color: #aa6; border: 1px solid #3a3a2a; }
.perm-edit { background: #1a2a1a; color: #6a6; border: 1px solid #2a3a2a; }
.perm-view { background: #1a1a2a; color: #88a; border: 1px solid #2a2a3a; }

/* Permission rows (in settings modal) */
.perm-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0;
    border-bottom: 1px solid #1a1a1a;
}

.perm-row-name {
    flex: 1;
    font-size: 0.85rem;
    color: #ccc;
}

.perm-row .btn-small {
    padding: 0.2rem 0.5rem;
    font-size: 0.75rem;
}

.lb-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.8rem;
    flex-wrap: wrap;
    background: #181818;
    border: 1px solid #2a2a2a;
    border-radius: 4px;
    padding: 0.5rem 0.6rem;
}

.lb-toolbar input[type="date"] {
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 4px;
    color: #e0e0e0;
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
    margin-bottom: 0;
}

.lb-day-label {
    font-size: 0.9rem;
    color: #777;
    margin-bottom: 0.8rem;
    padding: 0.3rem 0;
}

.lb-events {
    min-height: 200px;
}

.lb-empty, .lb-loading {
    color: #555;
    font-size: 0.85rem;
    text-align: center;
    padding: 2rem 0;
}

/* Snap toggle in toolbar */
.snap-toggle {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.78rem;
    color: #666;
    cursor: pointer;
    margin-left: auto;
    user-select: none;
}

.snap-toggle input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.snap-toggle span {
    position: relative;
    padding-left: 1.2rem;
    line-height: 1;
}

.snap-toggle span::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 0.75rem;
    height: 0.75rem;
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 2px;
    transition: background 0.15s, border-color 0.15s;
}

.snap-toggle span::after {
    content: '';
    position: absolute;
    left: 0.15rem;
    top: 50%;
    transform: translateY(-50%);
    width: 0.45rem;
    height: 0.45rem;
    background: transparent;
    border-radius: 1px;
    transition: background 0.15s;
}

.snap-toggle input:checked + span { color: #aaa; }
.snap-toggle input:checked + span::before { border-color: #2a3a2a; }
.snap-toggle input:checked + span::after { background: #6a6; }

/* Lifeboard tab content framing */
.lb-container .tab-content {
    background: #111;
    border: 1px solid #1e1e1e;
    border-radius: 0 0 6px 6px;
    padding: 1rem;
    margin-top: -1px;
}

.lb-container .tab-bar {
    border-bottom: none;
    background: #131313;
    border: 1px solid #222;
    border-radius: 6px 6px 0 0;
    padding: 0 0.4rem;
    margin-bottom: 0;
}

/* Event cards */
.event-card {
    background: #151515;
    border: 1px solid #252525;
    border-radius: 6px;
    padding: 0.8rem 1rem;
    margin-bottom: 0.6rem;
    cursor: pointer;
    transition: border-color 0.15s;
}
.event-card:hover {
    border-color: #444;
}

.event-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.3rem;
}

.event-time {
    font-size: 0.8rem;
    color: #777;
}

.event-title {
    font-size: 0.95rem;
    color: #ddd;
}

.event-desc {
    font-size: 0.8rem;
    color: #666;
    margin-top: 0.25rem;
}

/* Status badges */
.status-badge {
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.status-incoming { background: #1a2a1a; color: #6a6; border: 1px solid #2a3a2a; }
.status-in_progress { background: #2a2a1a; color: #aa6; border: 1px solid #3a3a2a; }
.status-passed { background: #1a1a2a; color: #88a; border: 1px solid #2a2a3a; }

/* Snap addon */
.snap-badge {
    font-size: 0.65rem;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    background: #2a1a2a;
    color: #a6a;
    border: 1px solid #3a2a3a;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.snap-toggle {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.8rem;
    color: #888;
    cursor: pointer;
    white-space: nowrap;
}
.snap-toggle input { cursor: pointer; }
.snap-toggle span { user-select: none; }

/* Addon sections in modals */
.addon-section {
    margin-top: 0.8rem;
    padding: 0.6rem 0.8rem;
    border: 1px solid #252525;
    border-radius: 4px;
    background: #0d0d0d;
}
.addon-toggle {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    color: #bbb;
    cursor: pointer;
}
.addon-toggle input { cursor: pointer; }
.input-small { width: 100px; }

/* Event preset cards */
.event-preset-card {
    background: #151515;
    border: 1px solid #252525;
    border-radius: 6px;
    padding: 0.8rem 1rem;
    margin-bottom: 0.6rem;
    cursor: pointer;
    transition: border-color 0.15s;
}
.event-preset-card:hover { border-color: #444; }
.event-preset-card .epst-title { font-size: 0.95rem; color: #ddd; }
.event-preset-card .epst-time { font-size: 0.8rem; color: #777; }
.event-preset-card .epst-meta { display: flex; gap: 0.5rem; align-items: center; margin-top: 0.2rem; }

/* Event progress bar */
.event-progress {
    margin-top: 0.4rem;
}
.event-progress-bar {
    height: 3px;
    background: #252525;
    border-radius: 2px;
    overflow: hidden;
}
.event-progress-fill {
    height: 100%;
    background: #aa6;
    border-radius: 2px;
    transition: width 1s linear;
    width: 0%;
}

/* Button variants */
.btn-accent {
    background: #1a2a1a;
    border-color: #2a3a2a;
    color: #6a6;
}
.btn-accent:hover { background: #223322; border-color: #3a4a3a; }

.btn-danger {
    background: #2a1a1a;
    border-color: #3a2a2a;
    color: #a66;
}
.btn-danger:hover { background: #332222; border-color: #4a3a3a; }

/* Addon sections (snap toggle in modals) */
.addon-section {
    margin-top: 0.8rem;
}

.addon-toggle {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    color: #999;
    cursor: pointer;
}

.addon-toggle input[type="checkbox"] { margin: 0; }

.input-small {
    width: 100px !important;
}

/* ==================== MODAL ==================== */

.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 10vh;
    z-index: 100;
}

.modal-content {
    background: #111;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 1.5rem;
    width: 100%;
    max-width: 440px;
}

.modal-content h3 {
    margin-bottom: 1rem;
    border-bottom: none;
    padding-bottom: 0;
    color: #ccc;
}

.modal-content label {
    display: block;
    font-size: 0.8rem;
    color: #777;
    margin-bottom: 0.3rem;
    margin-top: 0.8rem;
}

.modal-content input[type="text"],
.modal-content input[type="datetime-local"],
.modal-content input[type="date"],
.modal-content input[type="number"],
.modal-content textarea,
.modal-content select {
    width: 100%;
    padding: 0.6rem 0.8rem;
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 4px;
    color: #e0e0e0;
    font-size: 0.9rem;
    font-family: inherit;
    margin-bottom: 0;
}

.modal-content textarea {
    resize: vertical;
}

.modal-content select {
    appearance: auto;
}

.modal-row {
    display: flex;
    gap: 0.8rem;
}

.modal-field {
    flex: 1;
}

.modal-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.modal-actions button {
    flex: none;
    width: auto;
}

/* ==================== ADMIN PANEL ==================== */

.admin-container { max-width: 600px; }

.btn-admin {
    display: inline-block;
    padding: 0.6rem 1.2rem;
    background: #1a1a2a;
    border: 1px solid #2a2a3a;
    border-radius: 4px;
    color: #88a;
    text-decoration: none;
    font-size: 0.9rem;
}
.btn-admin:hover { background: #222233; border-color: #3a3a4a; }

/* ==================== ACCOUNT TABS ==================== */

.tab-bar {
    display: flex;
    gap: 0;
    border-bottom: 1px solid #333;
    margin-bottom: 1.5rem;
}

.tab-btn {
    width: auto;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    color: #666;
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
    cursor: pointer;
    margin-top: 0;
    transition: color 0.15s, border-color 0.15s;
}

.tab-btn:hover {
    color: #aaa;
    background: none;
    border-bottom-color: #444;
}

.tab-btn.active {
    color: #e0e0e0;
    border-bottom-color: #e0e0e0;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ==================== SESSION LIST ==================== */

.session-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.session-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.7rem 0.8rem;
    background: #151515;
    border: 1px solid #252525;
    border-radius: 6px;
    gap: 0.8rem;
}

.session-item.current { border-color: #2a3a2a; }

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

.session-device {
    font-size: 0.85rem;
    color: #ccc;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.session-current-badge {
    font-size: 0.7rem;
    padding: 0.1rem 0.4rem;
    background: #1a2a1a;
    border: 1px solid #2a3a2a;
    border-radius: 3px;
    color: #6a6;
}

.session-meta {
    font-size: 0.75rem;
    color: #555;
    margin-top: 0.2rem;
}

.session-revoke {
    width: auto;
    padding: 0.3rem 0.7rem;
    font-size: 0.75rem;
    margin-top: 0;
    background: #2a1a1a;
    border-color: #3a2a2a;
    color: #a66;
    flex-shrink: 0;
}

.session-revoke:hover {
    background: #332222;
    border-color: #4a3a3a;
}

.account-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.7rem 0;
    border-bottom: 1px solid #1a1a1a;
    gap: 1rem;
}

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

.account-name {
    font-size: 0.9rem;
    color: #ccc;
    display: block;
    margin-bottom: 0.3rem;
}

.account-tags { display: flex; flex-wrap: wrap; gap: 0.3rem; }

.account-actions {
    display: flex;
    gap: 0.3rem;
    flex-shrink: 0;
}

.account-actions .btn-small {
    padding: 0.3rem 0.6rem;
    font-size: 0.75rem;
}

/* Admin modal (reuses .modal-overlay) */
.modal {
    background: #111;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 1.5rem;
    width: 100%;
    max-width: 400px;
}

.modal h3 {
    margin-bottom: 1rem;
    border-bottom: none;
    padding-bottom: 0;
    color: #ccc;
}

/* Tag picker (admin panel) */
.tag-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.8rem;
}

.tag-picker-item {
    border-radius: 3px;
    padding: 0.3rem 0.7rem;
    font-size: 0.8rem;
    cursor: pointer;
    transition: opacity 0.15s;
    opacity: 0.35;
    border: 1px solid transparent;
}

.tag-picker-item.selected {
    opacity: 1;
}

.tag-picker-label {
    font-size: 0.8rem;
    color: #666;
    margin-bottom: 0.4rem;
}

/* ==================== PRESET CARDS ==================== */

.preset-card {
    background: #151515;
    border: 1px solid #252525;
    border-radius: 6px;
    padding: 0.8rem 1rem;
    margin-bottom: 0.6rem;
    transition: border-color 0.15s;
}
.preset-card:hover {
    border-color: #444;
}

.preset-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.3rem;
}

.preset-title {
    font-size: 0.95rem;
    color: #ddd;
}

.preset-count {
    font-size: 0.75rem;
    color: #666;
}

.preset-desc {
    font-size: 0.8rem;
    color: #666;
    margin-bottom: 0.5rem;
}

.preset-actions {
    display: flex;
    gap: 0.4rem;
}

.preset-actions .btn-small {
    padding: 0.3rem 0.7rem;
    font-size: 0.75rem;
}

/* Template event cards */
.template-card {
    background: #131313;
    border: 1px solid #222;
    border-radius: 4px;
    padding: 0.6rem 0.8rem;
    margin-bottom: 0.4rem;
    cursor: pointer;
    transition: border-color 0.15s;
}
.template-card:hover {
    border-color: #3a3a3a;
}

.template-time {
    font-size: 0.8rem;
    color: #777;
}

.template-title {
    font-size: 0.9rem;
    color: #ccc;
}

.template-desc {
    font-size: 0.75rem;
    color: #555;
    margin-top: 0.15rem;
}

/* Time input styling */
.modal-content input[type="time"] {
    width: 100%;
    padding: 0.6rem 0.8rem;
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 4px;
    color: #e0e0e0;
    font-size: 0.9rem;
    font-family: inherit;
    margin-bottom: 0;
}

/* Preset detail sub-view */
.preset-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #222;
}

.preset-back-btn {
    font-size: 0.85rem;
    color: #888;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    width: auto;
    margin: 0;
}
.preset-back-btn:hover {
    color: #ccc;
    background: none;
}

/* Apply preview */
.apply-preview-item {
    font-size: 0.8rem;
    color: #888;
    padding: 0.2rem 0;
    border-bottom: 1px solid #1a1a1a;
}

/* Chat Archive */
.archive-card {
    background: #161616;
    border: 1px solid #252525;
    border-radius: 6px;
    padding: 0.7rem 0.9rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: border-color 0.15s;
}
.archive-card:hover {
    border-color: #444;
}
.archive-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.3rem;
}
.archive-card-period {
    font-size: 0.85rem;
    color: #ccc;
    font-weight: 500;
    text-transform: capitalize;
}
.archive-card-key {
    font-size: 0.8rem;
    color: #777;
}
.archive-card-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.75rem;
    color: #555;
}
.archive-messages {
    max-height: 400px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    margin-bottom: 0.8rem;
}
.archive-msg {
    padding: 0.3rem 0.5rem;
    border-radius: 4px;
    font-size: 0.82rem;
    line-height: 1.4;
    background: #1a1a1a;
    border: 1px solid #252525;
}
.archive-msg-sender {
    font-size: 0.7rem;
    color: #777;
    margin-bottom: 0.1rem;
}
.archive-msg-content {
    color: #ccc;
    word-wrap: break-word;
}
.archive-msg-time {
    font-size: 0.6rem;
    color: #444;
    margin-top: 0.1rem;
}
