:root {
    --bg: #07080a;
    --fg: #f4f5f7;
    --muted: #a0a6b1;
    --dim: #5b626e;
    --accent: #6cd99a;
    --accent-hover: #7ee5a8;
    --accent-ink: #06210f;
    --field-bg: rgba(255, 255, 255, 0.035);
    --field-bg-strong: rgba(255, 255, 255, 0.06);
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.16);
    --danger: #ff6b6b;
    --radius: 16px;
    --radius-lg: 22px;
    --radius-pill: 999px;
    --serif: 'Newsreader', 'Iowan Old Style', 'Charter', Georgia, serif;
    --sans: 'Inter', -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: var(--sans);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
}

body {
    background:
        radial-gradient(ellipse 1100px 600px at 50% 0%, rgba(108, 217, 154, 0.045), transparent 60%),
        radial-gradient(ellipse 1400px 800px at 50% 110%, rgba(91, 125, 209, 0.045), transparent 60%),
        var(--bg);
}

a { color: inherit; }

/* ── auth pages (centered hero) ──────────────────────────────────── */

body.auth {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    position: relative;
}

body.auth::before {
    content: "";
    position: fixed;
    top: 50%;
    left: 50%;
    width: min(800px, 120vw);
    height: min(800px, 120vw);
    transform: translate(-50%, -55%);
    border-radius: 50%;
    background: radial-gradient(circle, rgba(108, 217, 154, 0.10) 0%, rgba(108, 217, 154, 0.035) 30%, transparent 60%);
    filter: blur(40px);
    z-index: 0;
    pointer-events: none;
    animation: breathe 9s ease-in-out infinite;
}

@keyframes breathe {
    0%, 100% { opacity: 0.55; transform: translate(-50%, -55%) scale(1); }
    50%      { opacity: 1;    transform: translate(-50%, -55%) scale(1.08); }
}

@keyframes rise {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

.signup, .notice {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 440px;
    padding: 48px 24px;
    text-align: center;
}

.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

.brand {
    font-family: var(--sans);
    font-weight: 600;
    letter-spacing: 0.18em;
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    margin-bottom: 56px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.brand .dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 14px rgba(108, 217, 154, 0.55);
    animation: pulse 2.4s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 10px rgba(108, 217, 154, 0.4); transform: scale(1); }
    50%      { box-shadow: 0 0 18px rgba(108, 217, 154, 0.75); transform: scale(1.15); }
}

h1 {
    font-family: var(--serif);
    font-size: clamp(36px, 6vw, 48px);
    font-weight: 400;
    letter-spacing: -0.02em;
    line-height: 1.1;
    margin: 0 0 14px;
    animation: rise 0.9s cubic-bezier(.2,.7,.2,1) both;
}

h1 em {
    font-style: italic;
    color: var(--accent);
    font-weight: 400;
}

.sub {
    color: var(--muted);
    font-size: 16px;
    line-height: 1.55;
    margin: 0 0 36px;
    animation: rise 1s cubic-bezier(.2,.7,.2,1) 0.1s both;
}

.signup-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    animation: rise 1s cubic-bezier(.2,.7,.2,1) 0.2s both;
}

input[type="tel"], input[type="text"], input[type="email"] {
    width: 100%;
    padding: 16px 20px;
    background: var(--field-bg);
    color: var(--fg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--sans);
    font-size: 17px;
    outline: none;
    transition: border-color 0.2s ease, background 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
}
input:focus {
    border-color: var(--border-strong);
    background: var(--field-bg-strong);
}

/* OTP code input — big, centered, monospaced for legibility */
input.otp {
    text-align: center;
    font-size: clamp(28px, 7vw, 38px);
    font-weight: 500;
    letter-spacing: 0.5em;
    padding: 22px 18px 22px 28px; /* compensate for letter-spacing right edge */
    font-variant-numeric: tabular-nums;
    font-family: 'SF Mono', 'Menlo', 'Roboto Mono', monospace;
}

.consent {
    color: var(--dim);
    font-size: 11.5px;
    line-height: 1.55;
    margin: 6px 4px 8px;
    text-align: left;
}
.consent a {
    color: var(--muted);
    text-decoration: underline;
    text-underline-offset: 2px;
}

button, a.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 15px 22px;
    background: var(--accent);
    color: var(--accent-ink);
    border: none;
    border-radius: var(--radius);
    font-family: var(--sans);
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.2px;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.15s ease;
}
button:hover, a.btn:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 10px 28px -10px rgba(108, 217, 154, 0.55);
}
button:active, a.btn:active { transform: translateY(0); }

button.ghost, a.btn.ghost {
    background: transparent;
    color: var(--fg);
    border: 1px solid var(--border);
}
button.ghost:hover, a.btn.ghost:hover {
    background: var(--field-bg-strong);
    border-color: var(--border-strong);
    box-shadow: none;
}

button.danger, a.btn.danger {
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--border);
}
button.danger:hover {
    color: var(--danger);
    border-color: rgba(255, 107, 107, 0.35);
    background: rgba(255, 107, 107, 0.05);
    box-shadow: none;
}

button.small, a.btn.small {
    width: auto;
    padding: 9px 16px;
    font-size: 13px;
    border-radius: var(--radius-pill);
}

button.pill, a.btn.pill { border-radius: var(--radius-pill); width: auto; padding: 11px 22px; font-size: 14px; }

.notice h1 { margin-bottom: 18px; }
.notice p { color: var(--muted); font-size: 17px; line-height: 1.6; }
.notice .instructions {
    text-align: left;
    border: 1px solid var(--border);
    background: var(--field-bg);
    border-radius: var(--radius-lg);
    padding: 22px 24px;
    margin: 28px 0 0;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.error {
    color: var(--danger);
    font-size: 13.5px;
    margin: 2px 2px 0;
}

.hint {
    color: var(--muted);
    font-size: 13.5px;
    margin-top: 28px;
    text-align: center;
}
.muted-link { color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.muted-link:hover { color: var(--fg); }

/* ── console layout ──────────────────────────────────────────────── */

body.console-body { display: block; }

.console-nav {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px clamp(16px, 4vw, 32px);
    border-bottom: 1px solid var(--border);
    background: rgba(7, 8, 10, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}
.console-nav .brand { margin: 0; font-size: 11px; }
.console-nav nav {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-wrap: wrap;
}
.console-nav nav a {
    color: var(--muted);
    text-decoration: none;
    font-size: 13.5px;
    padding: 7px 12px;
    border-radius: var(--radius-pill);
    transition: color 0.15s ease, background 0.15s ease;
}
.console-nav nav a:hover { color: var(--fg); background: var(--field-bg); }
.console-nav nav a.active { color: var(--fg); background: var(--field-bg-strong); }
.console-nav nav span.dim {
    color: var(--dim);
    font-size: 13.5px;
    padding: 7px 12px;
    text-decoration: line-through;
    opacity: 0.6;
}

.console {
    max-width: 760px;
    margin: 0 auto;
    padding: 48px clamp(16px, 4vw, 28px) 96px;
    display: block;
}

.console .hero { margin-bottom: 32px; }
.console .hero h1 {
    font-family: var(--serif);
    font-size: clamp(30px, 4.5vw, 40px);
    font-weight: 400;
    letter-spacing: -0.015em;
    margin: 0 0 10px;
    animation: rise 0.6s cubic-bezier(.2,.7,.2,1) both;
}
.console .hero p { margin: 4px 0; color: var(--muted); font-size: 15.5px; line-height: 1.55; }
.console .muted { color: var(--muted); }
.console .dim { color: var(--dim); }

/* Cards */
.card {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin: 16px 0;
    background: var(--field-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    position: relative;  /* anchor for popovers inside the card */
}

/* `.card` creates its own stacking context via backdrop-filter, so a
   popover inside one card can't paint over a sibling card by raising
   z-index alone. Cards containing a combo / dropdown get elevated above
   neighbours so the dropdown surfaces correctly. */
.card:has(.combo),
.card:has(.combo-list),
.card.elevated {
    z-index: 5;
}
.card h2 {
    font-family: var(--serif);
    font-weight: 500;
    font-size: 22px;
    letter-spacing: -0.01em;
    margin: 0 0 14px;
}
.card h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--dim);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    margin: 0 0 12px;
}

/* Steps (home) */
.steps { list-style: none; padding: 0; margin: 0; counter-reset: step; }
.steps li {
    counter-increment: step;
    padding: 18px 0;
    border-bottom: 1px solid var(--border);
    display: grid;
    grid-template-columns: 32px 1fr;
    gap: 18px;
    align-items: start;
}
.steps li:last-child { border-bottom: none; }
.steps li::before {
    content: counter(step);
    font-family: var(--serif);
    font-size: 22px;
    font-style: italic;
    color: var(--accent);
    line-height: 1;
    padding-top: 2px;
}
.steps li strong { display: block; font-weight: 500; font-size: 16px; margin-bottom: 4px; }
.steps li p { margin: 0; color: var(--muted); font-size: 14.5px; line-height: 1.5; }

/* Sectioned workflow catalog: one .wf-section per cadence group, each
   with a serif title + small count + a leading italic tagline. Matches
   the spec mock (one-top12-workflows.html) but folded into our existing
   dark-mode console look rather than the spec's light surface. */
.wf-section { margin-top: 40px; }
.wf-section:first-of-type { margin-top: 8px; }
.wf-section-head {
    display: flex;
    align-items: baseline;
    gap: 14px;
    margin-bottom: 6px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}
.wf-section-title {
    font-family: var(--serif);
    font-size: 22px;
    font-weight: 500;
    letter-spacing: -0.01em;
    margin: 0;
}
.wf-section-count {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--dim);
    font-weight: 600;
}
.wf-section-tag {
    font-size: 13.5px;
    color: var(--muted);
    font-style: italic;
    margin: 0 0 14px;
    line-height: 1.5;
}

/* Provider / workflow list */
.tiles {
    display: grid;
    gap: 12px;
    grid-template-columns: 1fr;
    list-style: none;
    padding: 0;
    margin: 0;
}
@media (min-width: 640px) {
    .tiles.two { grid-template-columns: 1fr 1fr; }
}

.tile {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px 20px;
    background: var(--field-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.tile:hover {
    border-color: var(--border-strong);
    background: var(--field-bg-strong);
    transform: translateY(-1px);
}

.tile .avatar {
    width: 44px; height: 44px;
    border-radius: 12px;
    background: var(--field-bg-strong);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--serif);
    font-size: 20px;
    font-weight: 500;
    color: var(--fg);
    flex-shrink: 0;
}
.tile .avatar.accent { color: var(--accent); border-color: rgba(108, 217, 154, 0.25); }

/* Logo avatars: hold a brand mark on a soft light surface so multi-color
   PNGs (Google, Slack) and silhouettes (Notion) all read well on the dark
   background. `invert` flips dark monochrome marks so they read on light. */
.tile .avatar.logo {
    background: #f4f5f7;
    border-color: rgba(255, 255, 255, 0.12);
    overflow: hidden;
    padding: 6px;
}
.tile .avatar.logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}
.tile .avatar.logo.accent {
    background: #f4f5f7;
    box-shadow: 0 0 0 1px rgba(108, 217, 154, 0.4), 0 0 18px -6px rgba(108, 217, 154, 0.5);
}
/* When the logo already has its own colored card (Granola, Todoist),
   drop the white tile and let the image bleed to the edges. */
.tile .avatar.logo.bleed {
    background: transparent;
    border-color: transparent;
    padding: 0;
}
.tile .avatar.logo.bleed img { border-radius: inherit; }
.tile .avatar.logo.bleed.accent {
    background: transparent;
    box-shadow: 0 0 0 1px rgba(108, 217, 154, 0.5), 0 0 18px -6px rgba(108, 217, 154, 0.5);
}
/* For PNGs with a baked-in opaque background (e.g. Todoist is RGB, not
   RGBA), scale the image so the unwanted border sits outside the
   `overflow: hidden` avatar clip. */
.tile .avatar.logo.zoom img { transform: scale(1.22); transform-origin: center; }

.tile .body { flex: 1; min-width: 0; }
.tile .title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
    font-size: 16px;
    margin-bottom: 3px;
}
.tile .desc {
    color: var(--muted);
    font-size: 13.5px;
    line-height: 1.45;
}
.tile .meta {
    color: var(--dim);
    font-size: 12px;
    margin-top: 4px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-weight: 600;
}

.tile .action { flex-shrink: 0; align-self: center; }
.tile .action form { margin: 0; }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 9px;
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border: 1px solid var(--border);
    color: var(--muted);
    background: var(--field-bg);
}
.badge.on {
    color: var(--accent);
    border-color: rgba(108, 217, 154, 0.35);
    background: rgba(108, 217, 154, 0.07);
}
.badge.on::before {
    content: "";
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 8px rgba(108, 217, 154, 0.6);
}
.badge.soon { color: var(--dim); }
.badge.off { color: var(--muted); }

/* Reveal toggle (eye icon next to phone) */
.reveal { display: inline-flex; align-items: center; gap: 10px; }
.reveal-value {
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
}
.reveal.shown .reveal-value { color: var(--fg); }
.icon-btn {
    width: 30px; height: 30px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.icon-btn:hover {
    color: var(--fg);
    border-color: var(--border-strong);
    background: var(--field-bg);
    transform: none;
    box-shadow: none;
}
.icon-btn .ico { width: 16px; height: 16px; display: block; }
.icon-btn .ico-off { display: none; }
.icon-btn[aria-pressed="true"] { color: var(--accent); border-color: rgba(108, 217, 154, 0.35); }
.icon-btn[aria-pressed="true"] .ico-open { display: none; }
.icon-btn[aria-pressed="true"] .ico-off { display: block; }

/* ── Account: profile rows ─────────────────────────────────────────── */
.profile { display: flex; flex-direction: column; gap: 4px; }
.profile-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
    min-height: 44px;
}
.profile-row:last-child { border-bottom: none; }
.profile-label {
    font-size: 12px;
    color: var(--dim);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 600;
}
.profile-row .badge { margin-left: 8px; }

/* ── Account: timezone card ────────────────────────────────────────── */
.tz-card { display: flex; flex-direction: column; gap: 20px; }
.tz-current-row {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 8px 4px 4px;
}
.tz-clock-big {
    font-family: var(--serif);
    font-size: clamp(40px, 7vw, 56px);
    font-weight: 400;
    letter-spacing: -0.02em;
    color: var(--accent);
    line-height: 1;
    font-variant-numeric: tabular-nums;
}
.tz-current-meta { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.tz-current-name {
    font-family: 'SF Mono', 'Menlo', monospace;
    font-size: 14px;
    color: var(--fg);
    word-break: break-all;
}
.tz-current-hint {
    font-size: 12px;
    color: var(--dim);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-weight: 600;
    min-height: 14px;
}

.tz-form {
    display: flex;
    gap: 10px;
    align-items: stretch;
    flex-wrap: wrap;
}
.tz-form .combo { position: relative; flex: 1; min-width: 220px; }
.tz-form input {
    width: 100%;
    padding: 12px 16px;
    background: var(--field-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--fg);
    font-family: var(--sans);
    font-size: 14.5px;
    outline: none;
    transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.tz-form input:focus {
    border-color: var(--border-strong);
    background: var(--field-bg-strong);
    box-shadow: 0 0 0 3px rgba(108, 217, 154, 0.08);
}
.tz-form button.accent {
    width: auto;
    padding: 0 22px;
    height: auto;
    font-size: 14px;
    border-radius: var(--radius);
    flex-shrink: 0;
    background: var(--accent);
    color: var(--accent-ink);
}
.tz-form button.accent:hover { background: var(--accent-hover); }

/* Combo dropdown: anchored under the input, same width, scrollable.
   z-index is high but only meaningful within the card's stacking context;
   the parent .card is elevated via .card:has(.combo) above to escape sibling
   cards entirely. */
.combo-list {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 50;
    max-height: 320px;
    overflow-y: auto;
    margin: 0;
    padding: 4px;
    list-style: none;
    background: #0f1115;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    box-shadow: 0 18px 48px -12px rgba(0, 0, 0, 0.6),
                0 0 0 1px rgba(255, 255, 255, 0.02);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    animation: rise 0.18s ease both;
}
.combo-opt {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 10px 14px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    color: var(--fg);
    transition: background 0.1s ease;
}
.combo-opt:hover, .combo-opt.active {
    background: rgba(108, 217, 154, 0.10);
    color: var(--fg);
}
.combo-opt.active { box-shadow: inset 0 0 0 1px rgba(108, 217, 154, 0.35); }
.combo-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.combo-off {
    color: var(--dim);
    font-family: 'SF Mono', 'Menlo', monospace;
    font-size: 12px;
    letter-spacing: 0.04em;
    flex-shrink: 0;
}

.tz-flash {
    margin: 0;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 13.5px;
}
.tz-flash.ok {
    color: var(--accent);
    background: rgba(108, 217, 154, 0.07);
    border: 1px solid rgba(108, 217, 154, 0.25);
}
.tz-flash.err {
    color: var(--danger);
    background: rgba(255, 107, 107, 0.06);
    border: 1px solid rgba(255, 107, 107, 0.25);
}

/* Key-value list */
.kv {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 12px 22px;
    margin: 0;
    align-items: baseline;
}
.kv dt {
    color: var(--dim);
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-weight: 600;
}
.kv dd { margin: 0; font-size: 15.5px; }

.section-title {
    font-family: var(--serif);
    font-size: 20px;
    font-weight: 500;
    margin: 32px 0 14px;
    letter-spacing: -0.01em;
}

hr.thin {
    border: none;
    border-top: 1px solid var(--border);
    margin: 24px 0;
}

/* Workflow detail (japanese-minimalist) */
.detail {
    max-width: 720px;
    margin: 0 auto;
    padding: 32px clamp(16px, 4vw, 28px) 96px;
}
.detail .crumb {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 13px;
    text-decoration: none;
    margin-bottom: 18px;
    letter-spacing: 0.02em;
}
.detail .crumb:hover { color: var(--fg); }
.detail h1 {
    font-family: var(--serif);
    font-size: clamp(36px, 5vw, 48px);
    font-weight: 400;
    letter-spacing: -0.02em;
    margin: 0 0 8px;
}
.detail .lede {
    font-family: var(--serif);
    font-style: italic;
    color: var(--accent);
    font-size: 18px;
    line-height: 1.5;
    margin: 0 0 36px;
    max-width: 540px;
}
.detail .meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 36px;
}

.prose {
    color: var(--fg);
    font-size: 15px;
    line-height: 1.7;
    white-space: pre-wrap;
    background: var(--field-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 22px;
    font-family: 'SF Mono', 'Menlo', 'Roboto Mono', monospace;
    font-size: 13px;
    color: var(--muted);
    max-height: 320px;
    overflow-y: auto;
}

/* ── workflow detail action row ──────────────────────────────────── */
.action-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 36px;
}
.action-row form { margin: 0; }

/* ── chat messages (used inside the drawer) ──────────────────────── */
.chat-log {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 18px 20px 8px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-height: 0;
}
.chat-empty {
    color: var(--dim);
    font-style: italic;
    font-family: var(--serif);
    text-align: center;
    margin: auto;
    padding: 40px 12px;
    font-size: 15px;
}
.chat-msg {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-width: 90%;
    animation: rise 0.25s ease both;
}
.chat-msg .who {
    font-size: 10.5px;
    color: var(--dim);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
}
.chat-msg .who .via {
    color: var(--accent);
    font-weight: 600;
    font-style: italic;
    margin-left: 4px;
}
.chat-msg .bubble {
    padding: 11px 15px;
    border-radius: 14px;
    font-size: 14.5px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.chat-msg.user { align-self: flex-end; align-items: flex-end; }
.chat-msg.user .bubble {
    background: rgba(108, 217, 154, 0.10);
    border: 1px solid rgba(108, 217, 154, 0.25);
    color: var(--fg);
}
.chat-msg.assistant .bubble {
    background: var(--field-bg-strong);
    border: 1px solid var(--border);
    color: var(--fg);
}
.chat-msg.change .bubble {
    background: rgba(108, 217, 154, 0.04);
    border: 1px dashed rgba(108, 217, 154, 0.35);
    color: var(--accent);
    font-family: 'SF Mono', 'Menlo', monospace;
    font-size: 12.5px;
}

/* ── slide-in chat drawer ────────────────────────────────────────── */
.drawer-scrim {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity 220ms ease;
    z-index: 90;
}
.drawer-scrim.open { opacity: 1; }

.drawer {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: min(520px, 100vw);
    background: var(--bg);
    border-left: 1px solid var(--border);
    box-shadow: -20px 0 60px -20px rgba(0, 0, 0, 0.6);
    transform: translateX(100%);
    transition: transform 240ms cubic-bezier(.2,.7,.2,1);
    z-index: 100;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.drawer.open { transform: translateX(0); }

body.drawer-open { overflow: hidden; }

.drawer-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 22px 22px 12px;
    border-bottom: 1px solid var(--border);
}
.drawer-eyebrow {
    font-size: 11px;
    color: var(--dim);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-weight: 600;
    margin-bottom: 4px;
}
.drawer-title {
    font-family: var(--serif);
    font-size: 22px;
    font-weight: 400;
    margin: 0;
    letter-spacing: -0.01em;
}
.drawer-close {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 999px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    cursor: pointer;
}
.drawer-close:hover { color: var(--fg); border-color: var(--border-strong); background: var(--field-bg-strong); }

.drawer-hint {
    font-size: 13px;
    line-height: 1.55;
    margin: 14px 22px 4px;
}

.drawer-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 0;
}

.drawer-input {
    border-top: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.2);
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.input-row {
    display: flex;
    gap: 10px;
    align-items: center;
}
.input-row input {
    flex: 1;
    padding: 12px 16px;
    background: var(--field-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    color: var(--fg);
    font-size: 15px;
    outline: none;
    transition: border-color 0.15s ease, background 0.15s ease;
    min-width: 0;
}
.input-row input:focus { border-color: var(--border-strong); background: var(--field-bg-strong); }
.input-row input:disabled { opacity: 0.6; }

.send-btn {
    width: auto;
    padding: 12px 22px;
    border-radius: var(--radius-pill);
    font-size: 14px;
    flex-shrink: 0;
    /* Stable: the spec is the send button NEVER moves, even while thinking. */
    transition: background 0.15s ease;
}
.send-btn:hover, .send-btn:active {
    transform: none !important;
    box-shadow: none !important;
}

/* ── mic button + recording banner ───────────────────────────────── */
.mic-btn {
    width: 42px;
    height: 42px;
    padding: 0;
    border-radius: 999px;
    background: var(--field-bg);
    border: 1px solid var(--border);
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
    box-shadow: none;
    cursor: pointer;
}
.mic-btn:hover:not(:disabled) { color: var(--fg); border-color: var(--border-strong); transform: none; }
.mic-btn:disabled { opacity: 0.5; cursor: wait; }
.mic-btn .ico { width: 18px; height: 18px; display: block; }
.mic-btn .ico-stop { display: none; }
.mic-btn[aria-pressed="true"] {
    background: rgba(255, 107, 107, 0.15);
    border-color: rgba(255, 107, 107, 0.45);
    color: var(--danger);
    animation: micPulse 1.6s ease-in-out infinite;
}
.mic-btn[aria-pressed="true"] .ico-mic { display: none; }
.mic-btn[aria-pressed="true"] .ico-stop { display: block; }
@keyframes micPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 107, 107, 0.25); }
    50%      { box-shadow: 0 0 0 6px rgba(255, 107, 107, 0); }
}

/* Recording banner sits ABOVE the input row. Hidden by default; .open is
   toggled by JS when actually recording. We deliberately base on
   `display: none` instead of relying on the [hidden] attribute alone —
   `display: flex` would otherwise outrank [hidden] and leave the banner
   stuck visible. */
.mic-banner {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 10px 12px 10px 14px;
    background: linear-gradient(
        90deg,
        rgba(255, 107, 107, 0.14) 0%,
        rgba(255, 107, 107, 0.08) 100%
    );
    border: 1px solid rgba(255, 107, 107, 0.32);
    border-radius: 14px;
    color: var(--danger);
    font-size: 13px;
    animation: rec-fade-in 180ms ease both;
}
.mic-banner.open { display: flex; }
.mic-banner[hidden] { display: none !important; }

@keyframes rec-fade-in {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Live waveform — 22 thin bars whose heights are driven by the Web Audio
   AnalyserNode in workflow_detail.html. Heights are set inline; CSS gives
   each bar its baseline shape + a subtle vertical gradient. */
.rec-wave {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 1;
    height: 26px;
    min-width: 0;
}
.rec-wave span {
    flex: 1;
    min-width: 2px;
    min-height: 2px;
    height: 2px;
    border-radius: 2px;
    background: linear-gradient(
        180deg,
        rgba(255, 138, 138, 0.95) 0%,
        rgba(255, 107, 107, 0.85) 100%
    );
    transition: height 70ms ease;
}

.rec-time {
    font-family: 'SF Mono', 'Menlo', monospace;
    font-variant-numeric: tabular-nums;
    font-size: 12px;
    letter-spacing: 0.04em;
    color: var(--danger);
    opacity: 0.85;
    flex-shrink: 0;
}
.rec-cancel {
    width: 26px;
    height: 26px;
    padding: 0;
    border-radius: 999px;
    background: transparent;
    border: 1px solid rgba(255, 107, 107, 0.45);
    color: var(--danger);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    cursor: pointer;
    transition: background 0.12s ease, border-color 0.12s ease;
}
.rec-cancel:hover {
    background: rgba(255, 107, 107, 0.18);
    border-color: rgba(255, 107, 107, 0.65);
    color: var(--danger);
    transform: none;
    box-shadow: none;
}

/* ── "thinking" indicator: stable position, 3 bouncing dots ────── */
.thinking {
    padding: 4px 20px 14px;
    display: none;
}
.thinking.htmx-request, .thinking.busy {
    display: block;
}
.thinking-bubble {
    display: inline-flex;
    gap: 4px;
    padding: 10px 14px;
    background: var(--field-bg-strong);
    border: 1px solid var(--border);
    border-radius: 14px;
    align-items: center;
}
.thinking-bubble span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--muted);
    animation: dotBounce 1.2s ease-in-out infinite;
}
.thinking-bubble span:nth-child(2) { animation-delay: 0.15s; }
.thinking-bubble span:nth-child(3) { animation-delay: 0.30s; }
@keyframes dotBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30%           { transform: translateY(-4px); opacity: 1; }
}

/* htmx default indicator class — keep generic rule but our specific
   .thinking rule above wins for the drawer. */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: block; }
.htmx-request.htmx-indicator { display: block; }

/* Mobile tweaks */
@media (max-width: 640px) {
    .console-nav { padding: 14px 16px; gap: 8px; }
    .console-nav nav a, .console-nav nav span.dim { padding: 6px 10px; font-size: 13px; }
    .console { padding: 28px 16px 80px; }
    .console .hero { margin-bottom: 24px; }
    .card { padding: 18px; border-radius: 18px; }
    .tile { padding: 14px 16px; gap: 12px; border-radius: 18px; }
    .tile .avatar { width: 38px; height: 38px; font-size: 17px; }
    .tile .title { font-size: 15px; }
    .detail { padding: 24px 16px 80px; }
    .drawer { width: 100vw; border-left: none; }
    .drawer-input { padding: 10px; }
    .input-row input { padding: 11px 14px; font-size: 14px; }
    .drawer-head { padding: 18px 18px 10px; }
    .drawer-hint { margin: 12px 18px 4px; font-size: 12.5px; }
    .signup, .notice { padding: 32px 16px; }
}
