:root {
    --bg: #000000;
    --surface: #111113;
    --surface-2: #1c1c1e;
    --surface-3: #2c2c2e;
    --text: #ffffff;
    --muted: #9a9aa0;
    --dim: #6d6d72;
    --border: rgba(84, 84, 88, 0.65);
    --accent: #0a84ff;
    --danger: #ff453a;
    --success: #34c759;
    --warning: #ffd60a;
    color-scheme: dark;
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    min-height: 100%;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    -webkit-font-smoothing: antialiased;
    text-size-adjust: 100%;
    overscroll-behavior: none;
}

body,
ion-app {
    background: var(--bg);
}

ion-content,
ion-toolbar,
ion-list,
ion-item {
    --background: var(--bg);
    --color: var(--text);
    font-family: inherit;
}

ion-toolbar {
    --border-color: var(--border);
}

ion-title {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0;
}

ion-input,
ion-note,
ion-label,
ion-button,
ion-toast,
ion-alert {
    font-family: inherit;
}

.app-container,
.view {
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--bg);
}

.view.hidden,
.hidden {
    display: none !important;
}

.header-icon-btn {
    --color: var(--accent);
}

.view-content {
    --background: var(--bg);
}

.timeline {
    --hour-height: 58px;
    --time-gutter: 58px;
    min-height: 100%;
    padding-bottom: calc(40px + env(safe-area-inset-bottom));
}

.timeline-loading {
    color: var(--muted);
    padding: 28px 0;
    text-align: center;
}

.timeline-day {
    border-bottom: 1px solid var(--border);
}

.timeline-day-body {
    position: relative;
}

.timeline-hour-grid {
    position: relative;
}

.timeline-day-header {
    position: sticky;
    top: 0;
    z-index: 5;
    display: grid;
    gap: 8px;
    padding: 12px 0 10px;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(16px);
}

.timeline-day-title {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

.timeline-day-name {
    margin: 0;
    font-size: 15px;
    line-height: 1.25;
    font-weight: 800;
}

.timeline-day-date {
    color: var(--muted);
    font-size: 12px;
}

.all-day-events {
    display: grid;
    gap: 6px;
}

.all-day-chip {
    display: grid;
    gap: 3px;
    padding: 8px 10px;
    border: 1px solid rgba(10, 132, 255, 0.5);
    border-radius: 8px;
    background: rgba(10, 132, 255, 0.14);
    color: var(--text);
    text-align: left;
    font: inherit;
}

.timeline-hour {
    display: grid;
    grid-template-columns: var(--time-gutter) minmax(0, 1fr);
    height: var(--hour-height);
    border-top: 1px solid rgba(84, 84, 88, 0.45);
}

.hour-label {
    padding-top: 8px;
    color: var(--dim);
    font-size: 11px;
    line-height: 1;
}

.hour-lane {
    min-width: 0;
    border-left: 1px solid rgba(84, 84, 88, 0.45);
}

.timeline-events-layer {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-columns: var(--time-gutter) minmax(0, 1fr);
    pointer-events: none;
}

.events-layer-gutter {
    pointer-events: none;
}

.events-layer-lane {
    position: relative;
    min-width: 0;
    pointer-events: none;
}

.event-card {
    position: absolute;
    top: var(--event-top);
    right: 0;
    left: 10px;
    height: var(--event-height);
    overflow: hidden;
    display: grid;
    align-content: start;
    gap: 5px;
    width: auto;
    margin: 0;
    padding: 9px 10px;
    border: 1px solid rgba(10, 132, 255, 0.52);
    border-radius: 8px;
    background: rgba(10, 132, 255, 0.15);
    color: var(--text);
    text-align: left;
    font: inherit;
    cursor: pointer;
    pointer-events: auto;
}

.event-title {
    overflow: hidden;
    color: var(--text);
    font-size: 14px;
    font-weight: 700;
    line-height: 1.3;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.event-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.35;
}

.event-meta span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.event-meta ion-icon {
    width: 13px;
    height: 13px;
}

.event-notes-preview {
    display: -webkit-box;
    overflow: hidden;
    margin: 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.45;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.settings-content {
    padding-bottom: calc(32px + env(safe-area-inset-bottom));
}

.settings-section-title {
    margin: 0;
    color: var(--text);
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
}

.settings-description {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.45;
    white-space: normal;
}

.settings-status-item {
    --min-height: 54px;
}

.sync-buttons {
    display: grid;
    gap: 10px;
    margin: 12px 0 20px;
}

.sync-buttons ion-button {
    min-height: 42px;
}

.sync-status,
.inline-status {
    min-height: 22px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.45;
}

.sync-status.success,
.inline-status.success {
    color: var(--success);
}

.sync-status.error,
.inline-status.error {
    color: var(--danger);
}

.inline-status.compact {
    min-height: 20px;
}

.pwa-update-status {
    max-width: 160px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.4;
    text-align: right;
}

.pwa-update-ready {
    color: var(--success);
}

.pwa-update-error {
    color: var(--danger);
}

.config-json-panel {
    margin: 8px 0 24px;
}

.config-json-panel textarea,
.edit-field,
.edit-textarea {
    width: 100%;
    min-height: 40px;
    border: 1px solid var(--border);
    border-radius: 8px;
    outline: none;
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
}

.config-json-panel textarea {
    padding: 10px;
    resize: vertical;
}

.event-form {
    display: grid;
    gap: 10px;
}

.form-label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.edit-field,
.edit-textarea {
    padding: 9px 10px;
}

.edit-textarea {
    line-height: 1.45;
    resize: vertical;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 38px;
    color: var(--text);
    font-size: 13px;
}

.checkbox-row input {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}

.form-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-top: 8px;
}

.empty-state {
    padding: 32px 12px;
    color: var(--muted);
    text-align: center;
}

@media (max-width: 560px) {
    .timeline {
        --time-gutter: 48px;
        padding-left: 10px;
        padding-right: 10px;
    }

    .form-actions {
        grid-template-columns: 1fr;
    }
}
