/* v2aDiary — app.css */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --color-primary: #00a8cc;
    --color-primary-dk: #0088aa;
    --color-danger: #e05555;
    --color-bg: #000e24;
    --color-surface: #0a1e3a;
    --color-text: #dde8f4;
    --color-muted: #6a88a8;
    --color-border: #1a3060;
    --color-header: #002060;
    --radius: 12px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --nav-h: 60px;
}

html, body {
    height: 100%;
    font-family: 'Segoe UI', Roboto, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior: none;
}

/* ── Header ── */
.app-header {
    background: var(--color-header);
    color: #fff;
    padding: .5rem 1.25rem;
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
}

.header-logo {
    height: 36px;
    width: auto;
    display: block;
}

/* ── Main content ── */
#app {
    padding: 1rem 1rem calc(var(--nav-h) + 1rem + var(--safe-bottom));
    max-width: 600px;
    margin: 0 auto;
}

h2 { font-size: 1.1rem; font-weight: 600; margin-bottom: .75rem; }
h3 { font-size: .95rem; font-weight: 600; margin: 1rem 0 .5rem; }

/* ── Bottom nav ── */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0; right: 0;
    height: calc(var(--nav-h) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    display: flex;
    z-index: 10;
}

.nav-btn {
    flex: 1;
    border: none;
    background: none;
    font-size: .75rem;
    color: var(--color-muted);
    cursor: pointer;
    padding: .5rem 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .2rem;
    transition: color .15s;
}
.nav-btn.active { color: var(--color-primary); font-weight: 600; }

/* ── Error bar ── */
.error-bar {
    background: rgba(224, 85, 85, 0.15);
    color: var(--color-danger);
    border-radius: var(--radius);
    padding: .6rem .75rem;
    margin-bottom: .75rem;
    font-size: .875rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .5rem;
}
.error-bar button {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    flex-shrink: 0;
}

/* ── Buttons ── */
.btn-primary {
    background: var(--color-primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: .65rem 1.25rem;
    font-size: .95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
}
.btn-primary:active { background: var(--color-primary-dk); }

.btn-secondary {
    background: none;
    color: var(--color-primary);
    border: 1.5px solid var(--color-primary);
    border-radius: 8px;
    padding: .65rem 1.25rem;
    font-size: .95rem;
    font-weight: 600;
    cursor: pointer;
}

.btn-sm { padding: .45rem .85rem; font-size: .85rem; }

.btn-delete,
.btn-edit {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    padding: .25rem;
    flex-shrink: 0;
    opacity: .6;
    transition: opacity .15s;
}
.btn-delete:active,
.btn-edit:active { opacity: 1; }

/* ── Mode toggle ── */
.mode-toggle {
    display: flex;
    align-items: center;
    gap: .6rem;
    align-self: center;
}

.mode-label {
    font-size: .8rem;
    color: var(--color-muted);
    transition: color .15s;
}
.mode-label.active {
    color: var(--color-primary);
    font-weight: 600;
}

.toggle-switch {
    position: relative;
    width: 44px;
    height: 26px;
    border-radius: 13px;
    background: var(--color-border);
    border: none;
    cursor: pointer;
    padding: 0;
    transition: background .2s;
    flex-shrink: 0;
}
.toggle-switch[aria-checked="true"] { background: var(--color-primary); }

.toggle-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,.2);
    transition: left .2s;
}
.toggle-thumb.right { left: 21px; }

/* ── Keyboard input ── */
.keyboard-wrap {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: .75rem;
}

.kb-textarea {
    width: 100%;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius);
    padding: .75rem 1rem;
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    outline: none;
    background: var(--color-surface);
    color: var(--color-text);
    line-height: 1.5;
}
.kb-textarea:focus { border-color: var(--color-primary); }

.spinner-sm {
    display: inline-block;
    width: 14px; height: 14px;
    border: 2px solid rgba(255,255,255,.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .7s linear infinite;
    vertical-align: middle;
    margin-right: .25rem;
}

/* ── Quick-trip tiles ── */
.quick-trips {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    margin-bottom: .5rem;
}

.quick-trips-label {
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--color-muted);
    margin-bottom: .1rem;
}

.route-tile {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: .2rem;
    width: 100%;
    min-height: 56px;
    background: var(--color-surface);
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius);
    padding: .75rem 1rem;
    text-align: left;
    cursor: pointer;
    transition: border-color .15s, background .15s;
    -webkit-tap-highlight-color: transparent;
}
.route-tile:active {
    background: #001a40;
    border-color: var(--color-primary);
}

.route-tile-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text);
}

.route-tile-meta {
    font-size: .8rem;
    color: var(--color-muted);
}

/* ── Record view ── */
.record-view {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    padding-top: 1rem;
}


.mic-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .75rem;
}

.mic-btn {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: none;
    background: var(--color-primary);
    color: #fff;
    font-size: 2.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(26,115,232,.35);
    transition: transform .1s, box-shadow .1s;
    -webkit-tap-highlight-color: transparent;
}
.mic-btn:active  { transform: scale(.93); }
.mic-btn.recording {
    background: var(--color-danger);
    box-shadow: 0 0 0 8px rgba(224,85,85,.25), 0 4px 16px rgba(224,85,85,.35);
    animation: pulse 1.4s ease-in-out infinite;
}
.mic-btn.busy { background: var(--color-muted); box-shadow: none; cursor: default; }

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 8px rgba(224,85,85,.25); }
    50%       { box-shadow: 0 0 0 16px rgba(224,85,85,.08); }
}

.mic-label {
    font-size: .9rem;
    color: var(--color-muted);
    min-height: 1.2em;
}

.transcript-box {
    width: 100%;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: .875rem 1rem;
    font-size: .95rem;
    line-height: 1.5;
    color: var(--color-text);
}

/* ── Spinner ── */
.spinner {
    width: 28px; height: 28px;
    border: 3px solid rgba(255,255,255,.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .7s linear infinite;
    display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Confirm view ── */
.confirm-view { display: flex; flex-direction: column; gap: .5rem; }

.field-row {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .45rem 0;
    border-bottom: 1px solid var(--color-border);
}
.field-row label {
    width: 90px;
    flex-shrink: 0;
    font-size: .82rem;
    color: var(--color-muted);
}
.field-row input,
.field-row select {
    flex: 1;
    border: none;
    background: none;
    font-size: .95rem;
    color: var(--color-text);
    font-family: inherit;
    outline: none;
    min-width: 0;
}
.field-static {
    font-size: .95rem;
    color: var(--color-text);
}

.confirm-actions {
    display: flex;
    gap: .75rem;
    margin-top: 1rem;
    border-bottom: none;
}

/* ── History view ── */
.history-view { display: flex; flex-direction: column; gap: .75rem; }

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: .75rem;
}
.filter-bar input {
    flex: 1;
    min-width: 120px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: .4rem .6rem;
    font-size: .85rem;
    font-family: inherit;
    outline: none;
}
.filter-bar input:focus { border-color: var(--color-primary); }

/* ── Export bar ── */
.export-bar {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.export-label {
    font-size: .8rem;
    color: var(--color-muted);
}

.btn-export {
    font-size: .8rem;
    font-weight: 600;
    color: var(--color-primary);
    border: 1.5px solid var(--color-primary);
    border-radius: 6px;
    padding: .3rem .7rem;
    text-decoration: none;
    transition: background .15s, color .15s;
}
.btn-export:active {
    background: var(--color-primary);
    color: #fff;
}

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
}
.card-header {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .6rem .875rem;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
}
.card-header strong { flex: 1; font-size: .95rem; }
.badge {
    font-size: .75rem;
    background: var(--color-primary);
    color: #fff;
    border-radius: 99px;
    padding: .15rem .5rem;
}
.card-body { padding: .6rem .875rem; display: flex; flex-direction: column; gap: .2rem; }
.card-meta { font-size: .82rem; color: var(--color-muted); }
.card-purpose { font-size: .85rem; font-style: italic; color: var(--color-muted); }

/* ── Locations view ── */
.locations-view { display: flex; flex-direction: column; gap: .75rem; }

.tab-bar {
    display: flex;
    border-bottom: 2px solid var(--color-border);
    margin-bottom: .25rem;
}
.tab-btn {
    flex: 1;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    padding: .6rem;
    font-size: .9rem;
    color: var(--color-muted);
    cursor: pointer;
    font-family: inherit;
}
.tab-btn.active { color: var(--color-primary); border-bottom-color: var(--color-primary); font-weight: 600; }

.item-list { list-style: none; display: flex; flex-direction: column; gap: .5rem; }
.item-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: .65rem .875rem;
    gap: .5rem;
}
.item-row > div { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.item-row strong { font-size: .95rem; }
.item-sub { font-size: .8rem; color: var(--color-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.add-form {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: .875rem;
}
.add-form input,
.add-form select {
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: .5rem .75rem;
    font-size: .9rem;
    font-family: inherit;
    outline: none;
    background: var(--color-bg);
}
.add-form input:focus,
.add-form select:focus { border-color: var(--color-primary); }

.empty { color: var(--color-muted); font-size: .9rem; padding: .5rem 0; }

/* ── About view ── */
.about-view {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    padding-top: 1rem;
    text-align: center;
}

.about-logo {
    width: 160px;
    height: 160px;
    object-fit: contain;
    border-radius: 24px;
}

.about-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--color-text);
}

.about-version {
    font-size: .85rem;
    color: var(--color-primary);
    font-weight: 600;
    margin-top: -.75rem;
}

.about-notes {
    width: 100%;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: .875rem 1rem;
    text-align: left;
}

.about-notes h3 {
    font-size: .9rem;
    font-weight: 700;
    margin-bottom: .75rem;
    color: var(--color-primary);
    text-transform: uppercase;
    letter-spacing: .06em;
}

.about-notes ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.about-notes li {
    font-size: .875rem;
    color: var(--color-muted);
    padding-left: 1rem;
    position: relative;
}

.about-notes li::before {
    content: '·';
    position: absolute;
    left: 0;
    color: var(--color-primary);
    font-weight: 700;
}

.about-notes li strong {
    color: var(--color-text);
    font-weight: 600;
}

.about-footer {
    font-size: .8rem;
    color: var(--color-muted);
}
