/* Phone layout for terransoul.com: flat near-black surfaces, pill and round controls, 44px+ targets, sticky top bar with
   a round menu button, bottom-anchored primary actions. Dark first; light when the visitor asks for it. Desktop is untouched. */

/* Menu and dock exist only on phones. */
.menu, .dock { display: none; }

@media (max-width: 760px) and (not (prefers-color-scheme: light)) {
  :root:not([data-theme='light']) {
    --paper: oklch(0.175 0.002 60);
    --ink: oklch(0.95 0.006 80);
    --clay: oklch(0.72 0.14 150);
    --paper-sunk: oklch(0.225 0.003 60);
    --paper-deep: oklch(0.26 0.004 60);
    --ink-soft: oklch(0.76 0.006 80);
    --ink-faint: oklch(0.66 0.006 80);
    --rule: oklch(0.3 0.004 60);
    --rule-strong: oklch(0.38 0.004 60);
    --clay-ink: oklch(0.82 0.13 150);
    --clay-soft: oklch(0.3 0.05 150);
    --clay-ring: oklch(0.45 0.08 150);
    --on-clay: oklch(0.15 0.01 150);
    --gutter: 1rem;
    --section-y: 2rem;
  }
}
@media (max-width: 760px) {
  :root[data-theme='dark'] {
    --paper: oklch(0.175 0.002 60);
    --ink: oklch(0.95 0.006 80);
    --clay: oklch(0.72 0.14 150);
    --paper-sunk: oklch(0.225 0.003 60);
    --paper-deep: oklch(0.26 0.004 60);
    --ink-soft: oklch(0.76 0.006 80);
    --ink-faint: oklch(0.66 0.006 80);
    --rule: oklch(0.3 0.004 60);
    --rule-strong: oklch(0.38 0.004 60);
    --clay-ink: oklch(0.82 0.13 150);
    --clay-soft: oklch(0.3 0.05 150);
    --clay-ring: oklch(0.45 0.08 150);
    --on-clay: oklch(0.15 0.01 150);
    --gutter: 1rem;
    --section-y: 2rem;
  }
}
@media (max-width: 760px) and (prefers-color-scheme: light) {
  :root:not([data-theme='dark']) { --clay: oklch(0.55 0.15 150); --clay-ink: oklch(0.38 0.12 150); --clay-soft: oklch(0.93 0.05 150); --clay-ring: oklch(0.8 0.08 150); --on-clay: oklch(0.99 0 0); --gutter: 1rem; --section-y: 2rem; }
}
@media (max-width: 760px) {
  :root[data-theme='light'] { --clay: oklch(0.55 0.15 150); --clay-ink: oklch(0.38 0.12 150); --clay-soft: oklch(0.93 0.05 150); --clay-ring: oklch(0.8 0.08 150); --on-clay: oklch(0.99 0 0); --gutter: 1rem; --section-y: 2rem; }
}

@media (max-width: 760px) {
  html { scroll-padding-top: 4.5rem; }
  body { font-size: 1.0625rem; line-height: 1.5; overflow-x: hidden; padding-bottom: calc(5.5rem + env(safe-area-inset-bottom)); }
  h1 { font-size: 2.1rem; line-height: 1.08; }
  h2 { font-size: 1.65rem; }
  .wrap { padding-left: max(1rem, env(safe-area-inset-left)); padding-right: max(1rem, env(safe-area-inset-right)); }

  /* Sticky top bar: logo circle and name left, round menu button right. */
  .top { position: sticky; top: 0; z-index: 20; background: var(--paper); border-bottom: 0; padding-top: env(safe-area-inset-top); }
  .top .wrap { min-height: 3.5rem; flex-wrap: nowrap; }
  .top.has-menu nav, .top.has-menu > .wrap > .theme, .top.has-menu > .wrap > .btn { display: none; }
  .top .mark { font-size: 1.25rem; min-height: 2.75rem; }
  .holo-btn { min-height: 2.75rem; padding: 0 1rem; }
  .top .mark img { width: 2.25rem; height: 2.25rem; padding: 0.4rem; border-radius: 50%; background: var(--paper-deep); }
  details.menu { display: block; position: relative; background: none; padding: 0; margin: 0; border-radius: 0; }
  details.menu summary { min-height: 2.75rem; display: grid; }
  .hero .actions .btn { display: none; } /* the dock carries Download and Open app */
  .menu summary { list-style: none; width: 2.75rem; height: 2.75rem; border-radius: 50%; background: var(--paper-sunk); display: grid; place-items: center; cursor: pointer; }
  .menu summary::-webkit-details-marker { display: none; }
  .bars, .bars::before, .bars::after { display: block; width: 1.1rem; height: 2px; background: var(--ink); border-radius: 2px; content: ''; position: relative; }
  .bars::before { position: absolute; top: -6px; }
  .bars::after { position: absolute; top: 6px; }
  .menu-sheet { position: absolute; right: 0; top: 3.5rem; width: min(18rem, calc(100vw - 2rem)); background: var(--paper-sunk); border: 1px solid var(--rule); border-radius: 24px; padding: 0.5rem; display: grid; gap: 0.25rem; box-shadow: 0 16px 40px rgb(0 0 0 / 0.4); }
  .menu-sheet a:not(.btn) { display: flex; align-items: center; min-height: 3rem; padding: 0 1rem; border-radius: 16px; color: var(--ink); text-decoration: none; font-size: 1.0625rem; }
  .menu-sheet a:not(.btn):active { background: var(--paper-deep); }
  .menu-sheet .theme, .menu-sheet .btn { min-height: 3rem; margin-top: 0.25rem; font-size: 1rem; }

  /* Pills and 44px+ targets. */
  .btn { min-height: 3rem; padding: 0.75rem 1.4rem; font-size: 1.0625rem; border-color: transparent; background: var(--paper-sunk); }
  .btn.primary { background: var(--clay); }
  .theme { min-height: 2.75rem; padding: 0 1rem; border-radius: 999px; background: var(--paper-deep); border-color: transparent; color: var(--ink); }
  .actions { margin: 1.25rem 0; }
  .actions .btn { flex: 1 1 100%; }
  .actions a:not(.btn) { display: inline-flex; align-items: center; min-height: 2.75rem; }
  main p a, main li a { display: inline-flex; align-items: center; min-height: 2.75rem; }
  .foot a, .top nav a { display: inline-flex; align-items: center; min-height: 2.75rem; }

  /* Flat sections: no hairlines, rounded surfaces instead. */
  section { border-top: 0; }
  .lede { font-size: 1.1875rem; }
  .stage.avatar { aspect-ratio: 3 / 4; border-radius: 28px; box-shadow: none; max-height: 70svh; width: 100%; }
  .frame { border-radius: 24px; }
  .frame.graph { aspect-ratio: 4 / 3; }
  pre.cmd { border-radius: 20px; padding: 1rem 1.1rem; }

  /* Bot list: big rows with round avatar, like a chat list. */
  .roster { gap: 0.25rem; }
  .bot { min-height: 4.5rem; padding: 0.6rem 0.9rem 0.6rem 0.6rem; border: 0; border-radius: 24px; background: var(--paper-sunk); gap: 0.9rem; }
  .bot:has(input:checked) { background: var(--clay-soft); }
  .pedestal { width: 3.25rem; height: 3.25rem; }
  .bot-name { font-size: 1.125rem; }
  .tag { border: 0; background: var(--paper-deep); color: var(--ink-soft); border-radius: 999px; padding: 0.15rem 0.6rem; }
  .bot-card, .room, .today { border-radius: 24px; border: 0; }
  .bot-card { padding: 0.5rem 1.25rem 1.25rem; }
  .today { background: var(--paper-sunk); padding: 1.25rem; border-top: 0; }
  .room-log li { background: var(--paper-deep); border-radius: 20px; padding: 0.7rem 1rem; }
  .room-log li.approval-card { border: 1px solid var(--rule-strong); }
  .chip { padding: 0.5rem 1rem; }

  /* Thinking modes, steps, facts: stacked rounded rows. */
  .modes { grid-template-columns: 1fr; gap: 0.5rem; border-top: 0; }
  .modes li { background: var(--paper-sunk); border-radius: 24px; padding: 1rem 1.25rem; }
  .ladder { border-top: 0; display: grid; gap: 0.5rem; }
  .ladder li { background: var(--paper-sunk); border-radius: 24px; border: 0; padding: 0.9rem 1.1rem; min-height: 3.5rem; align-items: center; }
  .ladder .state { padding: 0.15rem 0.7rem; }
  .figures, .figures tbody, .figures tr, .figures th, .figures td { display: block; width: 100%; }
  .figures tr { background: var(--paper-sunk); border-radius: 24px; padding: 1rem 1.25rem; margin-bottom: 0.5rem; }
  .figures th, .figures td { padding: 0; border: 0; }
  .figures td { color: var(--ink-soft); }
  .figures td.num { color: var(--ink); font-size: 2rem; margin: 0.15rem 0; }
  .privacy th { width: 100%; }

  /* Questions: chat-list rows. */
  details { max-width: none; background: var(--paper-sunk); border: 0; border-radius: 24px; padding: 0 1.25rem; margin-bottom: 0.5rem; }
  summary { min-height: 3.5rem; display: flex; align-items: center; }
  details[open] { padding-bottom: 1rem; }
  details p { margin-top: 0; }

  .foot { padding: 1.5rem 0; }
  .foot .wrap { gap: 0.25rem 1.25rem; }

  /* Bottom-anchored primary actions. */
  .dock { display: flex; position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; gap: 0.5rem; padding: 0.75rem max(1rem, env(safe-area-inset-right)) calc(0.75rem + env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left)); background: linear-gradient(to top, var(--paper) 70%, transparent); }
  .dock .btn { flex: 1; min-height: 3.25rem; border-radius: 999px; box-shadow: 0 4px 16px rgb(0 0 0 / 0.35); }
  .dock .btn:not(.primary) { background: var(--paper-deep); }
}
@media (min-width: 761px) { .menu-sheet { display: none; } }
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
