/* ============================================
   VoxList - iOS Reminders style
   Mobile-first design
   ============================================ */

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

html.app-loading,
html.app-loading body {
    height: 100%;
    overflow: hidden;
}

.app-loading-screen {
    position: fixed;
    inset: 0;
    background: var(--bg);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

html.app-loading .app-loading-screen {
    display: flex;
}

.app-loading-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 20px 24px;
    border-radius: 18px;
    background: var(--bg);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
    color: var(--text);
}

.app-loading-spinner {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    animation: app-loading-spin 0.9s linear infinite;
}

.app-loading-text {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.app-loading-dots {
    display: inline-flex;
    gap: 6px;
}

.app-loading-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-secondary);
    animation: app-loading-pulse 1.2s ease-in-out infinite;
}

.app-loading-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.app-loading-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes app-loading-spin {
    to { transform: rotate(360deg); }
}

@keyframes app-loading-pulse {
    0%, 100% { opacity: 0.35; transform: translateY(0); }
    50% { opacity: 1; transform: translateY(-3px); }
}

:root {
    /* Light theme (default) */
    --accent: #FF9500;
    --auth-accent: #FF9500;
    --accent-light: rgba(255, 149, 0, 0.12);
    --bg: #FFFFFF;
    --bg-group: #F2F2F7;
    --text: #000000;
    --text-secondary: #8E8E93;
    --text-tertiary: #C7C7CC;
    --border: #E5E5EA;
    --success: #34C759;
    --warning: #FF9500;
    --danger: #FF3B30;
    /* Touch targets: min 44px */
    --touch-min: 44px;
    --header-h: 56px;
    --tab-bar-h: 56px;
    --safe-bottom: env(safe-area-inset-bottom, 0);
    /* Content horizontal padding: header, list, and tab bar align on mobile */
    --content-padding-x: 16px;
    --safe-left: env(safe-area-inset-left, 0);
    --safe-right: env(safe-area-inset-right, 0);
}

[data-theme="dark"] {
    /* Dark theme */
    --accent: #FF9500;
    --auth-accent: #FF9500;
    --accent-light: rgba(255, 149, 0, 0.2);
    --bg: #000000;
    --bg-group: #1C1C1E;
    --text: #FFFFFF;
    --text-secondary: #8E8E93;
    --text-tertiary: #636366;
    --border: #38383A;
    --success: #30D158;
    --warning: #FF9F0A;
    --danger: #FF453A;
    --active-item-edit-input-bg: #2C2C2E;
    --active-item-edit-border: #48484A;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    padding-bottom: calc(var(--tab-bar-h) + var(--safe-bottom));
}

/* ---- Views ---- */
.view {
    display: none;
    min-height: 100vh;
}

.view.active {
    display: flex;
    flex-direction: column;
}

/* ---- Header (iOS style) ---- */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: var(--header-h);
    padding: 0 16px;
    padding-top: env(safe-area-inset-top, 0);
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.app-header .header-left,
.app-header .header-right {
    min-width: 70px;
    display: flex;
    align-items: center;
}

.app-header .header-right {
    justify-content: flex-end;
    gap: 4px;
}

.header-add-btn {
    font-size: 24px;
    font-weight: 300;
    line-height: 1;
    color: var(--accent);
}

/* Home & History: header inner aligns with list (same horizontal padding) */
.list-header.app-header {
    padding-left: 0;
    padding-right: 0;
}

.list-header .header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    padding-left: max(var(--content-padding-x), var(--safe-left));
    padding-right: max(var(--content-padding-x), var(--safe-right));
    min-height: var(--header-h);
}

.page-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--accent);
    text-align: left;
    flex: 1;
    padding-left: 4px;
    min-width: 0;
}

/* In Progress list view: fixed header + search, scrollable list */
#in-progress-list-view.view.active {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow: hidden;
}

#in-progress-list-view .in-progress-top-fixed {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    flex-shrink: 0;
    background: var(--bg);
    padding: 0 max(var(--content-padding-x), var(--safe-left)) 0 max(var(--content-padding-x), var(--safe-right));
}

#in-progress-list-view .in-progress-top-fixed .list-search-input {
    margin-top: 12px;
    margin-bottom: 12px;
}

#in-progress-list-view .in-progress-list-content {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    padding-top: calc(var(--header-h) + env(safe-area-inset-top, 0) + 76px);
}

#in-progress-list-view .in-progress-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

#in-progress-list-view .page-title,
#archived-view .page-title {
    flex: 0 1 auto;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Archived view: fixed header + search, scrollable list */
#archived-view.view.active {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow: hidden;
}

#archived-view .archived-top-fixed {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    flex-shrink: 0;
    background: var(--bg);
    padding: 0 max(var(--content-padding-x), var(--safe-left)) 0 max(var(--content-padding-x), var(--safe-right));
}

#archived-view .archived-top-fixed .list-search-input {
    margin-top: 12px;
    margin-bottom: 12px;
}

#archived-view .archived-list-content {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    padding-top: calc(var(--header-h) + env(safe-area-inset-top, 0) + 76px);
}

#archived-view .header-inner {
    justify-content: flex-start;
}

#archived-view .header-inner .header-left,
#archived-view .header-inner .header-right {
    display: none;
}


.header-title-center {
    font-size: 20px;
    font-weight: 700;
    color: var(--accent);
    flex: 1;
    text-align: center;
}

.back-btn {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 17px;
    min-height: var(--touch-min);
    min-width: var(--touch-min);
    padding: 0 8px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.header-text-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 14px;
    min-height: var(--touch-min);
    padding: 0 8px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.editor-done-btn {
    color: var(--accent);
}

.editor-done-icon {
    width: 24px;
    height: 24px;
}

.header-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--touch-min);
    height: var(--touch-min);
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.icon-gear,
.lucide-icon {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

.lucide-icon-inline {
    width: 1em;
    height: 1em;
    vertical-align: -0.2em;
    margin-right: 4px;
}

.empty-icon .lucide-icon {
    width: 48px;
    height: 48px;
    opacity: 0.5;
}

.group-icon .lucide-icon {
    width: 14px;
    height: 14px;
    color: var(--text-secondary);
}

.completion-icon .lucide-icon {
    width: 32px;
    height: 32px;
    color: var(--success);
}

.template-actions .lucide-icon,
.item-actions .lucide-icon {
    width: 20px;
    height: 20px;
}

.drag-handle .lucide-icon {
    width: 18px;
    height: 18px;
}

/* ---- Main content ---- */
.main-content {
    flex: 1;
    padding: 16px 16px 24px;
    padding-bottom: calc(24px + var(--safe-bottom));
    width: 100%;
}

/* Home & History: centered mobile-optimized space, content left-aligned inside (compact) */
.list-content {
    max-width: 600px;
    margin: 0 auto;
    padding: 10px max(var(--content-padding-x), var(--safe-right)) 12px max(var(--content-padding-x), var(--safe-left));
    padding-bottom: calc(12px + var(--safe-bottom));
    text-align: left;
}

/* ---- Home page redesign ---- */
.home-header {
    border-bottom: none;
}

#template-list-view .home-header .header-inner,
#template-list-view .home-header-inner {
    flex-direction: column;
    align-items: center;
    padding: 12px 16px 10px;
}

.home-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--accent);
    margin: 0;
    text-align: center;
}

.home-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 2px 0 0;
    font-weight: 400;
}

#template-list-view .home-content {
    background: var(--bg);
    padding-top: 4px;
}

#template-list-view .list-content {
    padding: 8px max(var(--content-padding-x), var(--safe-right)) calc(8px + var(--safe-bottom)) max(var(--content-padding-x), var(--safe-left));
}

/* Continue VoxList card */
.continue-voxlist-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    margin-bottom: 12px;
    background: var(--bg);
    border-radius: 12px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    border: 1px solid var(--border);
}

.continue-voxlist-card:active {
    opacity: 0.9;
}

.continue-card-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.continue-play-icon {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--accent);
    border-radius: 10px;
    color: var(--accent);
}

.continue-play-icon svg {
    width: 20px;
    height: 20px;
}

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

.continue-card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 1px;
}

.continue-template-name {
    font-size: 14px;
    font-weight: 400;
    color: var(--text);
    margin: 0;
}

.continue-progress {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 1px 0 0;
}

.continue-soundwaves {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 26px;
}

.continue-soundwaves span {
    width: 4px;
    background: var(--accent);
    border-radius: 2px;
    animation: soundwave 0.8s ease-in-out infinite alternate;
}

.continue-soundwaves span:nth-child(1) { height: 6px; animation-delay: 0s; }
.continue-soundwaves span:nth-child(2) { height: 12px; animation-delay: 0.1s; }
.continue-soundwaves span:nth-child(3) { height: 18px; animation-delay: 0.2s; }
.continue-soundwaves span:nth-child(4) { height: 14px; animation-delay: 0.3s; }
.continue-soundwaves span:nth-child(5) { height: 20px; animation-delay: 0.4s; }
.continue-soundwaves span:nth-child(6) { height: 8px; animation-delay: 0.5s; }
.continue-soundwaves span:nth-child(7) { height: 14px; animation-delay: 0.6s; }

@keyframes soundwave {
    from { transform: scaleY(0.5); }
    to { transform: scaleY(1); }
}

/* Home sections */
.home-section {
    margin-bottom: 18px;
}

.home-section-heading {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0 0 6px;
}

.home-voxlist-list {
    list-style: none;
    padding: 0;
    margin: 0;
    background: var(--bg);
    border-radius: 10px;
    border: 1px solid var(--border);
    overflow: hidden;
}

.home-voxlist-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.home-voxlist-list li:last-child {
    border-bottom: none;
}

.home-voxlist-list li:active {
    background: var(--bg-group);
}

.home-voxlist-item-info {
    flex: 1;
    min-width: 0;
}

.home-voxlist-item-title-row {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.home-voxlist-item-title {
    font-size: 15px;
    font-weight: 500;
    color: var(--text);
    margin: 0;
}

.home-voxlist-item-date {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 1px 0 0;
}

.home-voxlist-item-play {
    flex-shrink: 0;
    color: var(--text-secondary);
}

.home-voxlist-item-play svg {
    width: 18px;
    height: 18px;
}

.home-voxlist-item-restore {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    min-width: 34px;
    min-height: 34px;
    background: none;
    border: none;
    padding: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

.home-voxlist-item-restore:active {
    opacity: 0.7;
}

.home-voxlist-item-restore .lucide-icon {
    width: 18px;
    height: 18px;
}

.home-section-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 6px;
    min-height: 20px;
}

.home-section-empty {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0;
    flex: 1;
}

.home-more-btn {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    padding: 4px 0;
    -webkit-tap-highlight-color: transparent;
}

.home-more-btn:active {
    opacity: 0.7;
}

/* ---- Reminder-style list (home & history) ---- */
.reminder-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.reminder-list .template-item,
.reminder-list .history-item {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    min-height: 28px;
    padding: 5px 0;
    margin: 0 -4px;
    padding-left: 4px;
    padding-right: 4px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.reminder-list .template-item:first-child,
.reminder-list .history-item:first-child {
    padding-top: 2px;
}

.reminder-list .template-item:active,
.reminder-list .history-item:active {
    background: var(--bg-group);
    border-radius: 8px;
}

.reminder-check {
    width: 14px;
    height: 14px;
    border: 1.5px solid var(--text-tertiary);
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 1px;
}

.reminder-body {
    flex: 1;
    min-width: 0;
    text-align: left;
}

.reminder-body .template-info h3,
.reminder-body h3,
.reminder-title {
    font-size: 13px;
    font-weight: 400;
    color: var(--text);
    line-height: 1.2;
    text-align: left;
}

.reminder-meta,
.template-info p,
.reminder-body p {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 0;
    text-align: left;
}

.template-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.template-actions button {
    width: var(--touch-min);
    height: var(--touch-min);
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.template-actions button:active {
    opacity: 0.6;
}

/* Template list: same box style as home page (templates-view) */
#template-list.reminder-list {
    list-style: none;
    padding: 0;
    margin: 0;
    background: var(--bg);
    border-radius: 10px;
    border: 1px solid var(--border);
    overflow: hidden;
}

#template-list.reminder-list .template-item.template-item-stacked {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 10px 12px;
    margin: 0;
    min-height: auto;
    border: none;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

#template-list.reminder-list .template-item.template-item-stacked:last-child {
    border-bottom: none;
}

#template-list.reminder-list .template-item.template-item-stacked:active {
    background: var(--bg-group);
}

.template-info-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}

.template-title-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 0;
}

.template-info-row h3 {
    font-size: 15px;
    font-weight: 500;
    color: var(--text);
    margin: 0;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.shared-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    border-radius: 999px;
    background: var(--accent-light);
    color: var(--accent);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    flex-shrink: 0;
}

.template-item-count {
    font-size: 12px;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.template-actions-row {
    display: flex;
    align-items: center;
    gap: 4px;
}

.template-actions-row button {
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.template-actions-row button:active {
    opacity: 0.6;
}

.template-actions-row .lucide-icon {
    width: 18px;
    height: 18px;
}

/* Archived list: row clickable to open detail */
/* In progress section (home page, compact) */
/* In progress: card-style block for clear separation */
/* In progress list (on in-progress-list-view page) */
.in-progress-list .in-progress-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 12px 14px;
    background: var(--bg-group);
    border-radius: 12px;
    margin: 0 0 8px 0;
    list-style: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    border: 1px solid var(--border);
}

.in-progress-list .in-progress-item:last-child {
    margin-bottom: 0;
}

.in-progress-list .in-progress-item:active {
    background: var(--border);
}

.in-progress-list .in-progress-item .in-progress-name {
    font-size: 15px;
    font-weight: 500;
    color: var(--text);
    flex: 1;
    min-width: 0;
    text-align: left;
}

.in-progress-list .in-progress-item .in-progress-date {
    font-size: 12px;
    color: var(--text-secondary);
    flex-shrink: 0;
}

/* Start VoxList button (home page) */
.start-voxlist-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    max-width: 600px;
    margin: 0 0 16px;
    padding: 12px 18px;
    font-size: 16px;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, var(--accent) 0%, #E68600 100%);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 4px 14px rgba(255, 149, 0, 0.35);
    transition: transform 0.15s ease, box-shadow 0.2s ease;
}

.start-voxlist-btn:active {
    transform: scale(0.98);
}

.start-btn-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}


[data-theme="dark"] .start-voxlist-btn {
    box-shadow: 0 4px 20px rgba(255, 149, 0, 0.25);
}

/* Execution view share button */
.execution-share-btn {
    background: var(--accent);
    border: none;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    padding: 7px 12px;
    border-radius: 999px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 6px 14px rgba(255, 149, 0, 0.25);
}

.execution-share-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.execution-share-btn--compact {
    padding: 6px 10px;
    font-size: 12px;
}


.execution-share-btn:active {
    opacity: 0.7;
}

.templates-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.templates-ai-btn {
    background: #1f6feb;
    border: none;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    padding: 7px 12px;
    border-radius: 999px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 6px 14px rgba(31, 111, 235, 0.25);
}

.templates-ai-btn:active {
    opacity: 0.7;
}

.templates-ai-btn:focus-visible {
    outline: 2px solid #1f6feb;
    outline-offset: 2px;
}

/* Template picker modal */
.template-picker-modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0;
    overflow: hidden;
}

.share-invite-modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 3000;
}

.share-invite-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
}

.share-invite-panel {
    position: relative;
    z-index: 1;
    width: min(92vw, 360px);
    background: var(--bg);
    border-radius: 16px;
    padding: 18px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

[data-theme="dark"] .share-invite-panel {
    background: #1C1C1E;
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: 0 24px 50px rgba(0, 0, 0, 0.6);
}

.share-invite-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}

.share-invite-copy {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0;
}

.share-invite-input {
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
}

[data-theme="dark"] .share-invite-input {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.share-invite-status {
    min-height: 16px;
    font-size: 12px;
    color: var(--text-secondary);
}

.share-invite-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.ai-generate-modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 3100;
}

.ai-generate-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
}

.ai-generate-panel {
    position: relative;
    z-index: 1;
    width: min(94vw, 420px);
    max-height: 90vh;
    overflow-y: auto;
    background: var(--bg);
    border-radius: 18px;
    padding: 18px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

[data-theme="dark"] .ai-generate-panel {
    background: #1C1C1E;
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: 0 24px 50px rgba(0, 0, 0, 0.6);
}

.ai-generate-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.ai-generate-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}

.ai-generate-close {
    background: transparent;
    border: none;
    font-size: 18px;
    color: var(--text-secondary);
    cursor: pointer;
}

.ai-generate-label {
    font-size: 12px;
    color: var(--text-secondary);
}

.ai-generate-input,
.ai-generate-panel input,
.ai-generate-panel select,
.ai-generate-panel textarea {
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
}

[data-theme="dark"] .ai-generate-panel input,
[data-theme="dark"] .ai-generate-panel select,
[data-theme="dark"] .ai-generate-panel textarea {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.ai-generate-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ai-generate-row {
    display: grid;
    grid-template-columns: 100px 1fr;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.ai-generate-row label {
    text-align: left;
    color: var(--text-secondary);
}

.ai-generate-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text);
}

.ai-generate-checkbox input {
    margin: 0;
    width: auto;
    flex: 0 0 auto;
}

.ai-generate-status {
    min-height: 16px;
    font-size: 12px;
    color: var(--text-secondary);
}

.ai-generate-preview {
    border-top: 1px solid var(--border);
    padding-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ai-generate-items {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ai-generate-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: center;
}

.ai-generate-item input {
    margin: 0;
}

.ai-generate-remove {
    background: none;
    border: none;
    color: var(--danger);
    font-size: 12px;
    cursor: pointer;
}

.ai-generate-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

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

.insights-section {
    margin-bottom: 20px;
}

.insights-stats-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.insights-stat {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    background: var(--bg);
}

[data-theme="dark"] .insights-stat {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.12);
}

.insights-stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.insights-stat-value {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
}

.insights-coach-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.insights-status {
    min-height: 16px;
    font-size: 12px;
    color: var(--text-secondary);
    margin: 8px 0;
}

.insights-privacy {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.insights-privacy input {
    margin: 0;
    width: auto;
}

.insights-coach-card {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    background: var(--bg);
}

[data-theme="dark"] .insights-coach-card {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.12);
}

.insights-coach-headline {
    margin: 0 0 10px;
    font-size: 16px;
    font-weight: 600;
}

.insights-coach-subhead {
    margin: 12px 0 6px;
    font-size: 13px;
    color: var(--text-secondary);
}

.insights-coach-list {
    list-style: disc;
    margin: 0 0 0 18px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    color: var(--text);
}

.template-picker-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    touch-action: none;
}

.template-picker-panel {
    position: relative;
    width: 100%;
    max-width: 600px;
    height: 85vh;
    min-height: 400px;
    padding: 20px max(var(--content-padding-x), var(--safe-left)) calc(20px + env(safe-area-inset-bottom));
    background: var(--bg);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.template-picker-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 12px;
}

.template-picker-search {
    width: 100%;
    padding: 10px 14px;
    margin-bottom: 12px;
    font-size: 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg);
    color: var(--text);
}

.template-picker-search:focus {
    outline: none;
    border-color: var(--accent);
}

.template-picker-search::placeholder {
    color: var(--text-tertiary);
}

/* List page search bars (templates, in progress) */
.list-search-input {
    width: 100%;
    padding: 10px 14px;
    margin-bottom: 12px;
    font-size: 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg);
    color: var(--text);
}

.list-search-input:focus {
    outline: none;
    border-color: var(--accent);
}

.list-search-input::placeholder {
    color: var(--text-tertiary);
}

.template-picker-empty {
    padding: 24px 0;
    color: var(--text-secondary);
    font-size: 15px;
}

.template-picker-list {
    list-style: none;
    padding: 0;
    margin: 0 0 16px;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
}

.template-picker-list li {
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
    font-size: 17px;
    color: var(--text);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.template-picker-list li:active {
    background: var(--bg-group);
}

.template-picker-list li:last-child {
    border-bottom: none;
}

.template-picker-cancel {
    width: 100%;
}

/* Active item edit modal (execution view click-to-edit) */
.active-item-edit-modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    overflow: hidden;
}

.active-item-edit-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    touch-action: none;
}

.active-item-edit-panel {
    position: relative;
    width: 100%;
    max-width: 400px;
    padding: 20px;
    background: var(--bg);
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border);
}

.active-item-edit-heading {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 16px;
}

.active-item-edit-heading-icon {
    color: var(--accent);
    flex-shrink: 0;
}

.active-item-edit-title-input {
    width: 100%;
    padding: 12px 14px;
    margin-bottom: 16px;
    font-size: 16px;
    border: 1px solid var(--active-item-edit-border, #E8D5C4);
    border-radius: 12px;
    background: var(--active-item-edit-input-bg, #FBF6F0);
    color: var(--text);
    box-sizing: border-box;
}

.active-item-edit-title-input:focus {
    outline: none;
    border-color: var(--accent);
}

.active-item-edit-title-input::placeholder {
    color: var(--text-tertiary);
}

/* Segmented control: Active | Skipped */
.active-item-edit-segment {
    display: flex;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 16px;
    background: var(--bg-group);
    padding: 3px;
}

.active-item-edit-segment-btn {
    flex: 1;
    padding: 10px 14px;
    font-size: 15px;
    font-weight: 500;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.15s, color 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.active-item-edit-segment-btn:hover {
    color: var(--text);
}

.active-item-edit-segment-btn.selected {
    background: var(--active-item-edit-input-bg, #FBF6F0);
    color: var(--accent);
    border: 1px solid var(--accent);
}

.active-item-edit-notes-wrap {
    margin-bottom: 16px;
}

.active-item-edit-notes-input {
    width: 100%;
    min-height: 72px;
    padding: 12px 14px;
    font-size: 15px;
    font-family: inherit;
    border: 1px solid var(--active-item-edit-border, #E8D5C4);
    border-radius: 12px;
    background: var(--active-item-edit-input-bg, #FBF6F0);
    color: var(--text);
    resize: vertical;
    box-sizing: border-box;
}

.active-item-edit-notes-input:focus {
    outline: none;
    border-color: var(--accent);
}

.active-item-edit-notes-input::placeholder {
    color: var(--text-tertiary);
}

/* Remove from this run */
.active-item-edit-remove-row {
    margin-bottom: 20px;
}

.active-item-edit-remove-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 14px;
    font-size: 15px;
    font-weight: 500;
    border: 1px solid var(--active-item-edit-border, #E8D5C4);
    border-radius: 12px;
    background: var(--active-item-edit-input-bg, #FBF6F0);
    color: var(--text);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.active-item-edit-remove-btn:hover {
    border-color: var(--accent);
}

.active-item-edit-remove-icon {
    color: var(--danger);
    flex-shrink: 0;
}

.active-item-edit-remove-hint {
    margin: 6px 0 0;
    font-size: 13px;
    color: var(--text-secondary);
}

/* Bottom actions */
.active-item-edit-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.active-item-edit-actions .btn {
    min-height: 44px;
    font-size: 16px;
    font-weight: 500;
    border-radius: 12px;
}

.active-item-edit-cancel-btn {
    background: var(--bg-group);
    border: 1px solid var(--border);
    color: var(--text);
}

.active-item-edit-cancel-btn:hover {
    background: var(--text-tertiary);
    border-color: var(--text-tertiary);
}

.active-item-edit-save-btn {
    background: var(--accent);
    border: none;
    color: white;
}

.active-item-edit-save-btn:hover {
    opacity: 0.9;
}

/* Delete confirm (same structure as Edit This Step: heading + actions) */
.active-item-edit-delete-confirm {
    padding: 0;
}

.active-item-edit-confirm-heading {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 20px;
    line-height: 1.3;
}

.active-item-edit-confirm-heading-icon {
    color: var(--danger);
    flex-shrink: 0;
}

.active-item-edit-delete-confirm .active-item-edit-actions {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.active-item-edit-confirm-actions .btn {
    grid-column: auto;
}

.active-item-edit-confirm-yes-btn {
    background: var(--danger);
    color: white;
    border: none;
}

.active-item-edit-confirm-yes-btn:hover {
    opacity: 0.9;
}

/* Templates view: fixed header, scrollable list */
#templates-view.view.active {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow: hidden;
}

#templates-view .templates-top-fixed {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    flex-shrink: 0;
    background: var(--bg);
    padding: 0 max(var(--content-padding-x), var(--safe-left)) 0 max(var(--content-padding-x), var(--safe-right));
}

#templates-view .templates-top-fixed .list-search-input {
    margin-top: 12px;
    margin-bottom: 12px;
}

#templates-view .templates-header-fixed {
    position: relative;
}

#templates-view .templates-list-content {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    padding-top: calc(var(--header-h) + env(safe-area-inset-top, 0) + 76px);
}

#templates-view .main-content {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

/* Templates view: header with dark title + prominent orange add button */
.templates-header .templates-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.templates-page-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--accent);
    margin: 0;
    flex: 1;
    text-align: left;
}

.templates-add-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 2px 8px rgba(255, 149, 0, 0.35);
    flex-shrink: 0;
}

.templates-add-btn .add-template-icon {
    width: 20px;
    height: 20px;
}

.templates-add-btn:active {
    opacity: 0.9;
    transform: scale(0.96);
}

/* Templates section */
#templates-view .templates-section {
    padding: 12px 0 24px;
    max-width: 600px;
    margin: 0 auto;
}

.templates-section {
    padding-top: 12px;
}

.add-template-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.add-template-btn:active {
    opacity: 0.9;
}

.add-template-icon {
    width: 18px;
    height: 18px;
}

.add-template-label {
    line-height: 1;
}

/* Archived template detail view (read-only items, no execution) */
.archived-detail-item-list {
    list-style: none;
    margin: 0 0 24px 0;
    padding: 0;
}

.archived-detail-item-list li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    font-size: 17px;
    color: var(--text);
}

.archived-detail-item-list li .item-index {
    min-width: 24px;
    color: var(--text-secondary);
    font-size: 15px;
}

.archived-detail-actions {
    margin-top: 24px;
}

/* ---- FAB ---- */
.fab {
    position: fixed;
    right: 20px;
    bottom: calc(var(--tab-bar-h) + 16px + var(--safe-bottom));
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    border: none;
    box-shadow: 0 4px 14px rgba(255, 149, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 50;
    -webkit-tap-highlight-color: transparent;
}

.fab:active {
    transform: scale(0.96);
}

.fab-icon {
    font-size: 28px;
    font-weight: 300;
    line-height: 1;
}

#template-editor-view .fab,
#execution-view .fab,
#history-view .fab,
#settings-view .fab {
    display: none;
}


/* ---- Empty state (home, compact) ---- */
.empty-state {
    text-align: left;
    padding: 24px 0;
    max-width: 320px;
    margin: 0 auto 0 0;
}

#home-empty-state {
    text-align: center;
    padding: 40px 24px;
    max-width: 280px;
    margin: 0 auto;
}

#home-empty-state .empty-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-light);
    border-radius: 50%;
    opacity: 1;
}

#home-empty-state .empty-icon .lucide-icon {
    width: 32px;
    height: 32px;
    color: var(--accent);
    opacity: 1;
}

#home-empty-state h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
}

#home-empty-state p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* In progress list page empty state */
#in-progress-list-empty {
    text-align: center;
    padding: 60px 24px;
    max-width: 280px;
    margin: 0 auto;
}

#in-progress-list-empty .empty-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-light);
    border-radius: 50%;
    opacity: 1;
}

#in-progress-list-empty .empty-icon .lucide-icon {
    width: 32px;
    height: 32px;
    color: var(--accent);
    opacity: 1;
}

#in-progress-list-empty h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
}

#in-progress-list-empty p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.empty-icon {
    font-size: 40px;
    margin-bottom: 10px;
    opacity: 0.5;
}

.empty-state h2 {
    font-size: 17px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

.empty-state p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.3;
}

/* ---- Editor (Edit VoxList) - matches home/template list design ---- */
#template-editor-view.view.active {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    height: 100vh;
    overflow: hidden;
}

#template-editor-view .editor-header {
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 3;
    background: var(--bg);
}

#template-editor-view .editor-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    padding-left: max(var(--content-padding-x), var(--safe-left));
    padding-right: max(var(--content-padding-x), var(--safe-right));
    min-height: var(--header-h);
}

#template-editor-view .editor-done-btn {
    color: var(--accent);
}

#template-editor-view .editor-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    max-width: 600px;
    margin: 0 auto;
    padding: 0 max(var(--content-padding-x), var(--safe-right)) calc(12px + var(--safe-bottom)) max(var(--content-padding-x), var(--safe-left));
}

.editor-name-section {
    position: sticky;
    top: 0;
    background: var(--bg);
    z-index: 4;
    padding-top: 12px;
    padding-bottom: 12px;
    margin-bottom: 0;
    border-bottom: 1px solid var(--border);
}

.editor-section {
    margin-bottom: 14px;
}

/* form-group used by settings and other forms */
.form-group {
    margin-bottom: 24px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.editor-section-heading {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.editor-text-input {
    width: 100%;
    padding: 8px 12px;
    font-size: 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg);
    color: var(--text);
}

.editor-text-input:focus {
    outline: none;
    border-color: var(--accent);
}

.editor-text-input::placeholder {
    color: var(--text-tertiary);
}

.editor-item-list {
    list-style: none;
    padding: 0;
    margin: 0 0 12px;
    background: var(--bg);
    border-radius: 10px;
    border: 1px solid var(--border);
    overflow: hidden;
}

.editor-item-list .item-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-bottom: 1px solid var(--border);
    cursor: default;
    touch-action: pan-y;
    min-height: 36px;
    background: var(--bg);
}

.editor-item-list .item-row:last-child {
    border-bottom: none;
}

.editor-item-list .item-row:active {
    background: var(--bg-group);
}

.item-row.dragging {
    opacity: 0.5;
}

.item-row.drag-over {
    border-top: 2px solid var(--accent);
}

.item-row .drag-handle {
    color: var(--text-tertiary);
    font-size: 16px;
    padding: 6px;
    cursor: grab;
    flex-shrink: 0;
    touch-action: none;
}

.item-row .item-text {
    flex: 1;
    font-size: 14px;
    color: var(--text);
    padding: 2px 0;
    cursor: text;
    min-height: 20px;
    display: flex;
    align-items: center;
}

.item-text-input {
    flex: 1;
    font-size: 14px;
    padding: 6px;
    border: 2px solid var(--accent);
    border-radius: 8px;
    background: var(--bg);
}

.item-row .item-actions button {
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.editor-section .add-item-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

.add-item-row .editor-text-input {
    flex: 1;
    margin: 0;
}

.add-item-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    border: none;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ---- Execution view: fixed top pane, list scrolls underneath ---- */
#execution-view {
    padding-bottom: 0;
}

.execution-top-pane {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 50;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    max-width: 600px;
    margin: 0 auto;
}

.execution-top-pane .progress-section {
    padding: 0 16px 10px;
    margin-bottom: 0;
}

.execution-top-pane .progress-section .progress-bar-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 4px;
}

.execution-top-pane .progress-section .progress-bar-row .progress-bar {
    flex: 1;
    min-width: 0;
}

.start-from-top-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    background: #007AFF;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
}

.start-from-top-btn:active {
    opacity: 0.9;
    transform: scale(0.96);
}

.execution-content {
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
    padding: 0 16px;
    padding-top: calc(var(--header-h) + env(safe-area-inset-top, 0) + 50px);
    padding-bottom: calc(140px + var(--tab-bar-h) + var(--safe-bottom));
    min-height: 100vh;
    overflow-y: auto;
}

.execution-content .voxlist-items-section {
    padding-bottom: 0;
}

.execution-bottom-panel {
    position: fixed;
    bottom: calc(var(--tab-bar-h) + var(--safe-bottom));
    left: 0;
    right: 0;
    background: var(--bg);
    border-top: 1px solid var(--border);
    padding: 10px 16px;
    max-width: 600px;
    margin: 0 auto;
    z-index: 100;
}

.execution-play-toggle {
    position: fixed;
    right: 20px;
    bottom: calc(var(--tab-bar-h) + var(--safe-bottom) + 92px);
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #007AFF;
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 18px rgba(0, 122, 255, 0.35);
    cursor: pointer;
    z-index: 120;
    -webkit-tap-highlight-color: transparent;
}

.execution-play-toggle:active {
    transform: scale(0.96);
}

.execution-play-toggle:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.execution-play-toggle .lucide-icon {
    width: 24px;
    height: 24px;
}

.progress-section {
    margin-bottom: 10px;
}

.progress-text {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.progress-bar {
    height: 3px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.current-item-section {
    margin-bottom: 0;
    min-height: 0;
    padding: 0;
}

.current-item-actions {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px;
    margin-top: 8px;
}

.current-item-actions .btn {
    min-height: 36px;
    padding: 8px 8px;
    font-size: 14px;
}

.completion-message {
    text-align: center;
    padding: 12px;
}

.completion-icon {
    font-size: 32px;
    color: var(--success);
    margin-bottom: 6px;
}

.completion-message h2 {
    font-size: 17px;
    font-weight: 600;
    color: var(--text);
}

.voxlist-items-section {
    margin-top: 8px;
}

#execution-view .section-heading,
.voxlist-items-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.execution-item-list {
    list-style: none;
}

/* When list is complete, items are not editable */
.execution-item-list.execution-list-complete .execution-item {
    cursor: default;
}

.execution-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    min-height: 36px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.execution-item.current {
    background: rgba(255, 149, 0, 0.25);
    margin: 0 -16px;
    padding-left: 16px;
    padding-right: 16px;
    border-left: 3px solid var(--accent);
}

.execution-item-status {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid var(--border);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    font-size: 10px;
}

.execution-item.completed .execution-item-status {
    background: var(--success);
    border-color: var(--success);
    color: white;
}

/* Skipped items: greyed/disabled look; row stays clickable to open edit modal. */
.execution-item.skipped {
    opacity: 0.7;
}

.execution-item.skipped .execution-item-text {
    color: var(--text-secondary);
}

.execution-item.skipped .execution-item-status {
    background: transparent;
    border-color: var(--text-secondary);
}

.execution-item.not-done .execution-item-status {
    background: transparent;
    border-color: var(--text-secondary);
}

.execution-item.current .execution-item-status {
    border-color: var(--accent);
    border-width: 2px;
}

.execution-item.current .execution-item-text {
    font-weight: 600;
    color: var(--text);
}

.execution-item-text {
    flex: 1;
    font-size: 15px;
    color: var(--text);
}

.execution-item.completed .execution-item-text {
    color: var(--text-secondary);
    text-decoration: line-through;
}

/* Manual controls removed - Skip button moved to bottom panel */

.btn {
    width: 100%;
    min-height: var(--touch-min);
    padding: 14px 20px;
    font-size: 17px;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.btn:active {
    opacity: 0.8;
}

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

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

.btn-secondary {
    background: var(--bg-group);
    color: var(--text);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-warning {
    background: var(--warning);
    color: white;
}

/* ---- History (matches Archived VoxList Templates list style) ---- */
#history-view .header-inner {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding-left: max(var(--content-padding-x), var(--safe-left));
    padding-right: max(var(--content-padding-x), var(--safe-right));
}

#history-view .history-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.history-group {
    list-style: none;
    margin-bottom: 12px;
}

.history-group-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}

.history-group-header {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: none;
    border: none;
    border-bottom: 1px solid var(--border);
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    text-align: left;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.history-group-card:not(.expanded) .history-group-header {
    border-bottom: none;
}

.group-icon {
    font-size: 12px;
    color: var(--text-secondary);
    transition: transform 0.2s;
}

.group-label {
    flex: 1;
}

.group-count {
    font-size: 13px;
    font-weight: 400;
    color: var(--text-secondary);
}

.history-group-items {
    list-style: none;
    padding: 0;
    margin: 0;
}

.history-group-card .history-group-items.home-voxlist-list {
    background: transparent;
    border: none;
    border-radius: 0;
}

.history-group-card .history-group-items .home-voxlist-item:last-child {
    border-bottom: none;
}

/* ---- Settings (matches home page card design) ---- */
#settings-view .header-inner {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding-left: max(var(--content-padding-x), var(--safe-left));
    padding-right: max(var(--content-padding-x), var(--safe-right));
}

#settings-view .header-inner .header-left,
#settings-view .header-inner .header-right {
    display: none;
}

.settings-content {
    max-width: 600px;
    margin: 0 auto;
}

.settings-section-card {
    margin-bottom: 20px;
}

.settings-section-heading {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 6px;
}

.settings-card {
    background: var(--bg);
    border-radius: 10px;
    border: 1px solid var(--border);
    overflow: hidden;
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: none;
    border-radius: 0;
}

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

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

.settings-row-label {
    display: block;
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.settings-row-desc {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.settings-row-value {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.settings-passkey-status {
    margin: 8px 12px 0;
}

.setting-toggle {
    width: 44px;
    height: 24px;
    accent-color: var(--accent);
    flex-shrink: 0;
}

.setting-voice-row {
    flex-direction: column;
    align-items: stretch;
}

.setting-voice-row .settings-row-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.setting-voice-row .voice-select {
    width: 100%;
    padding: 10px 36px 10px 12px;
    font-size: 15px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238E8E93' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    cursor: pointer;
}

.settings-test-btn {
    margin: 12px 16px;
    padding: 12px 20px;
    width: calc(100% - 32px);
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    background: var(--bg-group);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.settings-test-btn:active {
    background: var(--border);
}

.settings-nav-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    padding: 12px 16px;
    border: none;
    border-bottom: 1px solid var(--border);
    background: none;
    text-align: left;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.settings-nav-row:last-child {
    border-bottom: none;
}

.settings-nav-row:active {
    background: var(--bg-group);
}

.settings-nav-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.settings-nav-label {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.settings-nav-desc {
    font-size: 12px;
    color: var(--text-secondary);
}

.settings-nav-chevron {
    flex-shrink: 0;
    color: var(--text-secondary);
}

.settings-nav-chevron svg {
    width: 20px;
    height: 20px;
}

.settings-logout-row .settings-nav-label {
    color: var(--accent);
}

/* ---- Tab bar: same horizontal padding as header/list, labels under icons ---- */
.tab-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    min-height: calc(var(--tab-bar-h) + var(--safe-bottom));
    padding: 6px max(var(--content-padding-x), var(--safe-left)) calc(6px + var(--safe-bottom)) max(var(--content-padding-x), var(--safe-right));
    background: var(--bg);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.tab-btn {
    flex: 1;
    max-width: 200px;
    min-height: 48px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.tab-btn .tab-label {
    font-size: 10px;
    font-weight: 500;
    color: inherit;
}

.tab-btn.active {
    color: var(--accent);
}

.tab-btn.active .tab-label {
    color: var(--accent);
}

.tab-btn:disabled,
.tab-btn.tab-btn-in-progress:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: auto;
}

.tab-icon {
    font-size: 24px;
}

.tab-icon-svg,
.tab-bar .lucide-icon {
    width: 24px;
    height: 24px;
}

/* ---- Desktop: slightly more padding, still aligned ---- */
@media (min-width: 600px) {
    :root {
        --content-padding-x: 24px;
    }

    .list-content {
        padding-left: var(--content-padding-x);
        padding-right: var(--content-padding-x);
    }

    .list-header .header-inner {
        padding-left: var(--content-padding-x);
        padding-right: var(--content-padding-x);
    }

    .main-content {
        padding-left: 24px;
        padding-right: 24px;
    }

    .tab-bar {
        padding-left: var(--content-padding-x);
        padding-right: var(--content-padding-x);
    }

    .fab {
        right: 24px;
        bottom: calc(var(--tab-bar-h) + 24px + var(--safe-bottom));
    }
}

@media (min-width: 768px) {
    .manual-controls {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ---- Auth / Onboarding view ---- */
/* Hide tab bar on auth and register (start / create account pages when not logged in) */
#auth-view.active ~ .tab-bar,
#register-view.active ~ .tab-bar,
#forgot-password-view.active ~ .tab-bar,
#reset-password-view.active ~ .tab-bar {
    display: none;
}
.auth-register-link-wrap {
    margin-top: 12px;
    text-align: center;
}
.auth-register-link {
    background: none;
    border: none;
    font-size: 15px;
    color: #34C759;
    cursor: pointer;
    text-decoration: none;
    padding: 0;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
.auth-register-link:hover {
    text-decoration: underline;
}
.auth-forgot-wrap {
    margin-top: 8px;
    margin-bottom: 4px;
}
.auth-forgot-link {
    background: none;
    border: none;
    font-size: 14px;
    color: var(--link-color, #007AFF);
    cursor: pointer;
    text-decoration: none;
    padding: 0;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
.auth-forgot-link:hover {
    text-decoration: underline;
}
.register-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}
.auth-back-btn {
    margin: 0;
}
.register-title {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
}
#register-view .auth-header,
#register-view .auth-content,
#forgot-password-view .auth-header,
#forgot-password-view .auth-content,
#reset-password-view .auth-header,
#reset-password-view .auth-content {
    padding-left: var(--content-padding-x);
    padding-right: var(--content-padding-x);
}
.register-content {
    padding-top: 24px;
}
.register-content .auth-form {
    max-width: 100%;
}
#auth-view .auth-header {
    justify-content: center;
    text-align: center;
    border-bottom: none;
    /* Keep logo below notch/Dynamic Island; minimum top padding when safe-area is 0 */
    padding-top: max(env(safe-area-inset-top, 0px), 16px);
}
#auth-view .auth-header,
#auth-view .auth-content {
    padding-left: var(--content-padding-x);
    padding-right: var(--content-padding-x);
}

.auth-header-inner {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    text-align: center;
}

#auth-view .auth-header-inner {
    /* Override .list-header .header-inner so logo, title, and subtitle are centered */
    justify-content: center;
}

.auth-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.auth-brand-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.auth-logo {
    display: inline-flex;
    flex-shrink: 0;
}

.auth-logo svg {
    display: block;
}

.auth-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}

.auth-subtitle {
    font-size: 15px;
    color: var(--text-secondary);
    margin-top: 6px;
    text-align: center;
}

.auth-content {
    flex: 1;
    padding-top: 24px;
    padding-bottom: 24px;
    overflow-y: auto;
}

html.has-auth-token #auth-view {
    display: none;
}

.auth-copy {
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: 24px;
    line-height: 1.4;
}

.auth-forms {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.auth-section-heading {
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: 0;
    margin-bottom: 12px;
}

.auth-section:nth-of-type(2) .auth-section-heading {
    text-transform: uppercase;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: 0.5px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.auth-input {
    width: 100%;
    min-height: var(--touch-min);
    padding: 0 14px;
    font-size: 17px;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    -webkit-appearance: none;
    appearance: none;
}

.auth-input::placeholder {
    color: var(--text-tertiary);
}

.auth-remember {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    color: var(--text);
    cursor: pointer;
}

.auth-remember input {
    width: 20px;
    height: 20px;
    accent-color: #007AFF;
    cursor: pointer;
}

.auth-status {
    min-height: 20px;
    font-size: 14px;
    color: var(--danger, #c00);
    margin-top: 8px;
    margin-bottom: 4px;
}

.auth-status:empty {
    display: none;
}

.auth-submit {
    min-height: var(--touch-min);
    font-size: 17px;
    font-weight: 600;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    background: var(--accent) !important;
    color: #fff !important;
    border: none;
    border-radius: 10px;
    width: 100%;
}

.auth-passkey-wrap {
    margin-top: 12px;
}

.auth-passkey-btn {
    font-weight: 600;
}

.auth-oauth-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.auth-google-one-tap:empty {
    display: none;
}

.auth-oauth-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    min-height: var(--touch-min);
    font-size: 17px;
    font-weight: 500;
    color: var(--text);
    background: var(--bg) !important;
    border: 1px solid var(--border);
    border-radius: 10px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.auth-oauth-icon {
    display: inline-flex;
    flex-shrink: 0;
}

.auth-oauth-icon-apple {
    color: var(--text);
}

.auth-dev {
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.auth-dev .btn {
    display: block;
    width: 100%;
    margin-bottom: 8px;
}

.auth-connect-api-wrap {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    text-align: center;
}
.auth-connect-api-note {
    display: block;
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}
.auth-continue-wrap {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
    text-align: center;
}

.auth-link {
    background: none;
    border: none;
    font-size: 15px;
    color: var(--accent);
    cursor: pointer;
    text-decoration: none;
    padding: 0;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.auth-link:hover {
    text-decoration: underline;
}

.auth-continue-note {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 8px;
}
