/* ============================================================
 * Hiroi Personal Assistant — Consumer UI
 * Calm, editorial, single-column. Apple/ChatGPT/Claude rest energy.
 * Brand accent: Hiroi teal (#0d9488 / #2dd4bf). Used sparingly.
 * ============================================================ */

:root {
  /* Surface */
  --as-bg:           #fbfaf7;   /* warm paper */
  --as-surface:      #ffffff;
  --as-surface-2:    #f4f1ec;
  --as-surface-hover:#efebe4;
  --as-overlay:      rgba(20, 18, 16, 0.40);

  /* Ink */
  --as-text:         #1a1816;
  --as-text-2:       #56514b;
  --as-text-3:       #8a847d;
  --as-text-on-accent:#ffffff;

  /* Lines */
  --as-line:         #ece8e1;
  --as-line-strong:  #d6d0c7;

  /* One accent. */
  --as-accent:       #0f766e;
  --as-accent-2:     #0d9488;
  --as-accent-soft:  rgba(15, 118, 110, 0.08);
  --as-accent-ring:  rgba(15, 118, 110, 0.18);

  /* Status (used sparingly) */
  --as-good:         #047857;
  --as-warn:         #b45309;
  --as-bad:          #b91c1c;

  /* Radius */
  --as-r-xs: 6px;
  --as-r-sm: 10px;
  --as-r-md: 14px;
  --as-r-lg: 20px;
  --as-r-xl: 28px;
  --as-r-full: 9999px;

  /* Shadow */
  --as-shadow-1: 0 1px 2px rgba(20, 18, 16, 0.04);
  --as-shadow-2: 0 4px 16px -6px rgba(20, 18, 16, 0.10), 0 1px 2px rgba(20, 18, 16, 0.04);
  --as-shadow-3: 0 12px 40px -16px rgba(20, 18, 16, 0.18);

  /* Motion */
  --as-ease:     cubic-bezier(0.4, 0, 0.2, 1);
  --as-ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --as-ease-spring: cubic-bezier(0.34, 1.4, 0.64, 1);
  --as-dur-fast: 140ms;
  --as-dur:      220ms;
  --as-dur-slow: 360ms;

  /* Type — repointed to the shared Voltage tokens (Geist / Geist Mono).
     The former --as-font-serif now maps to the shared UI face: no serif anywhere. */
  --as-font-sans:  var(--f-ui);
  --as-font-serif: var(--f-ui);
  --as-font-mono:  var(--f-mono);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-as-theme="light"]) {
    --as-bg:           #0d0c0a;
    --as-surface:      #16140f;
    --as-surface-2:    #1d1a14;
    --as-surface-hover:#22201a;
    --as-overlay:      rgba(0,0,0,0.55);

    --as-text:         #ede9e1;
    --as-text-2:       #a8a098;
    --as-text-3:       #6e6962;
    --as-text-on-accent:#0d0c0a;

    --as-line:         #2a2620;
    --as-line-strong:  #3a352d;

    --as-accent:       #2dd4bf;
    --as-accent-2:     #14b8a6;
    --as-accent-soft:  rgba(45, 212, 191, 0.10);
    --as-accent-ring:  rgba(45, 212, 191, 0.22);

    --as-shadow-1: 0 0 0 1px rgba(255,255,255,0.04);
    --as-shadow-2: 0 0 0 1px rgba(255,255,255,0.05), 0 8px 24px -8px rgba(0,0,0,0.5);
    --as-shadow-3: 0 0 0 1px rgba(255,255,255,0.07), 0 16px 48px -12px rgba(0,0,0,0.6);
  }
}

/* ============================================================
 * Base
 * ============================================================ */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--as-bg);
  color: var(--as-text);
  font-family: var(--as-font-sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input, textarea, select {
  font-family: inherit;
  color: inherit;
}

::selection {
  background: var(--as-accent-soft);
  color: var(--as-accent);
}

/* Custom scrollbar — thin, restrained */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--as-line-strong) transparent;
}
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--as-line-strong);
  border-radius: var(--as-r-full);
  border: 2px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--as-text-3); background-clip: padding-box; border: 2px solid transparent; }

/* ============================================================
 * Layout
 * ============================================================ */

.as-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.as-nav {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(251, 250, 247, 0.85);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--as-line);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-as-theme="light"]) .as-nav {
    background: rgba(13, 12, 10, 0.80);
  }
}
.as-nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.as-wordmark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--as-text);
  text-decoration: none;
}
.as-brand-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--as-text);
  color: var(--as-bg);
  flex-shrink: 0;
}
.as-brand-icon svg {
  width: 18px;
  height: 18px;
}
.as-brand-text {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--as-text);
}
.as-voice-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
@media (max-width: 600px) {
  .as-voice-grid { grid-template-columns: 1fr; }
}
.as-voice-card { padding: 14px; }

.as-nav-cta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.as-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--as-surface-2);
  border: 1px solid var(--as-line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  color: var(--as-text-2);
  cursor: pointer;
  transition: border-color var(--as-dur) var(--as-ease), background var(--as-dur) var(--as-ease);
}
.as-avatar:hover { border-color: var(--as-line-strong); }

.as-dropdown {
  position: relative;
}
.as-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 200px;
  background: var(--as-surface);
  border: 1px solid var(--as-line);
  border-radius: var(--as-r-md);
  box-shadow: var(--as-shadow-2);
  padding: 6px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity var(--as-dur) var(--as-ease), transform var(--as-dur) var(--as-ease);
}
.as-dropdown.open .as-dropdown-menu {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.as-dropdown-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 12px;
  border-radius: var(--as-r-xs);
  font-size: 14px;
  color: var(--as-text);
  transition: background var(--as-dur-fast) var(--as-ease);
}
.as-dropdown-item:hover { background: var(--as-surface-2); }
.as-dropdown-divider {
  height: 1px;
  background: var(--as-line);
  margin: 6px 4px;
}

.as-footer {
  margin-top: auto;
  padding: 32px 24px 40px;
  text-align: center;
  font-size: 13px;
  color: var(--as-text-2);
  border-top: 1px solid var(--as-line);
}
.as-footer-links {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-bottom: 8px;
}
.as-footer-links a {
  color: var(--as-text-2);
  transition: color var(--as-dur) var(--as-ease);
}
.as-footer-links a:hover { color: var(--as-text); }

/* ============================================================
 * Typography
 * ============================================================ */

.as-h1 {
  font-family: var(--as-font-serif);
  font-weight: 500;
  font-size: clamp(40px, 7vw, 76px);
  line-height: 1.04;
  letter-spacing: -0.03em;
  margin: 0;
  color: var(--as-text);
}
.as-h2 {
  font-family: var(--as-font-serif);
  font-weight: 500;
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--as-text);
}
.as-h3 {
  font-family: var(--as-font-serif);
  font-weight: 500;
  font-size: 22px;
  line-height: 1.3;
  letter-spacing: -0.015em;
  margin: 0;
  color: var(--as-text);
}
.as-eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--as-accent);
}
.as-lead {
  font-size: 19px;
  line-height: 1.5;
  color: var(--as-text-2);
}
.as-muted { color: var(--as-text-3); }

/* ============================================================
 * Buttons
 * ============================================================ */

.as-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 20px;
  border-radius: var(--as-r-full);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.005em;
  transition: background var(--as-dur) var(--as-ease), color var(--as-dur) var(--as-ease), transform var(--as-dur) var(--as-ease-spring), box-shadow var(--as-dur) var(--as-ease);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.as-btn:focus-visible {
  outline: 2px solid var(--as-accent);
  outline-offset: 2px;
}
.as-btn:active { transform: scale(0.97); }
.as-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.as-btn-primary {
  background: var(--as-text);
  color: var(--as-bg);
}
.as-btn-primary:hover:not(:disabled) {
  background: var(--as-accent);
  color: var(--as-text-on-accent);
}

.as-btn-accent {
  background: var(--as-accent);
  color: var(--as-text-on-accent);
}
.as-btn-accent:hover:not(:disabled) {
  background: var(--as-accent-2);
}

.as-btn-ghost {
  background: transparent;
  color: var(--as-text);
}
.as-btn-ghost:hover:not(:disabled) {
  background: var(--as-surface-2);
}

.as-btn-outline {
  background: transparent;
  color: var(--as-text);
  box-shadow: inset 0 0 0 1px var(--as-line-strong);
}
.as-btn-outline:hover:not(:disabled) {
  box-shadow: inset 0 0 0 1px var(--as-text);
}

.as-btn-danger {
  background: var(--as-bad);
  color: #fff;
}

.as-btn-sm { height: 36px; padding: 0 14px; font-size: 14px; }
.as-btn-lg { height: 52px; padding: 0 28px; font-size: 16px; }

.as-btn-icon-only {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
}

/* ============================================================
 * Cards
 * ============================================================ */

.as-card {
  background: var(--as-surface);
  border: 1px solid var(--as-line);
  border-radius: var(--as-r-md);
  padding: 24px;
  transition: border-color var(--as-dur) var(--as-ease), box-shadow var(--as-dur) var(--as-ease);
}
.as-card-interactive { cursor: pointer; }
.as-card-interactive:hover { border-color: var(--as-line-strong); box-shadow: var(--as-shadow-2); }

.as-card-section {
  background: var(--as-surface);
  border: 1px solid var(--as-line);
  border-radius: var(--as-r-md);
  overflow: hidden;
}
.as-card-section-header {
  padding: 20px 24px 12px;
  border-bottom: 1px solid var(--as-line);
}
.as-card-section-header h3 {
  font-family: var(--as-font-serif);
  font-size: 19px;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: 0 0 4px;
}
.as-card-section-header p {
  font-size: 13px;
  color: var(--as-text-3);
  margin: 0;
}
.as-card-section-body { padding: 20px 24px; }

/* ============================================================
 * Forms
 * ============================================================ */

.as-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 18px;
}
.as-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--as-text-2);
  letter-spacing: -0.005em;
}
.as-input,
.as-textarea,
.as-select {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  background: var(--as-surface);
  border: 1px solid var(--as-line-strong);
  border-radius: var(--as-r-sm);
  font-size: 15px;
  color: var(--as-text);
  transition: border-color var(--as-dur) var(--as-ease), box-shadow var(--as-dur) var(--as-ease);
}
.as-input:focus,
.as-textarea:focus,
.as-select:focus {
  outline: none;
  border-color: var(--as-accent);
  box-shadow: 0 0 0 3px var(--as-accent-ring);
}
.as-textarea {
  height: auto;
  padding: 12px 14px;
  resize: vertical;
  min-height: 96px;
  line-height: 1.5;
}
.as-help {
  font-size: 12px;
  color: var(--as-text-3);
}

.as-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}
.as-toggle input { display: none; }
.as-toggle-track {
  width: 38px;
  height: 22px;
  background: var(--as-line-strong);
  border-radius: var(--as-r-full);
  position: relative;
  transition: background var(--as-dur) var(--as-ease);
}
.as-toggle-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
  transition: transform var(--as-dur) var(--as-ease-spring);
}
.as-toggle input:checked + .as-toggle-track {
  background: var(--as-accent);
}
.as-toggle input:checked + .as-toggle-track::after {
  transform: translateX(16px);
}

/* Chip option group */
.as-chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  background: var(--as-surface-2);
  border: 1px solid var(--as-line);
  border-radius: var(--as-r-full);
  font-size: 13px;
  color: var(--as-text-2);
  cursor: pointer;
  transition: all var(--as-dur) var(--as-ease);
}
.as-chip:hover { border-color: var(--as-line-strong); color: var(--as-text); }
.as-chip-active {
  background: var(--as-accent-soft);
  border-color: var(--as-accent);
  color: var(--as-accent);
}

/* ============================================================
 * Conversation surface
 * ============================================================ */

.as-workspace {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 0;
  min-height: calc(100vh - 60px);
}
@media (max-width: 768px) {
  .as-workspace {
    grid-template-columns: 1fr;
  }
  .as-rail { display: none; }
  .as-rail.open { display: block; position: fixed; inset: 60px 0 0; z-index: 30; background: var(--as-bg); }
}

.as-rail {
  border-right: 1px solid var(--as-line);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 60px;
  height: calc(100vh - 60px);
  overflow-y: auto;
}
.as-rail-section h4 {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--as-text-3);
  margin: 0 8px 8px;
}
.as-rail-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: var(--as-r-sm);
  font-size: 14px;
  color: var(--as-text-2);
  transition: all var(--as-dur-fast) var(--as-ease);
}
.as-rail-link:hover { background: var(--as-surface-2); color: var(--as-text); }
.as-rail-link.active { background: var(--as-accent-soft); color: var(--as-accent); font-weight: 500; }
.as-rail-link .as-rail-badge {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: var(--as-r-full);
  background: var(--as-accent);
  color: var(--as-text-on-accent);
  font-weight: 600;
}
.as-rail-event {
  padding: 10px 12px;
  font-size: 13px;
  color: var(--as-text-2);
  background: var(--as-surface-2);
  border-radius: var(--as-r-sm);
  margin-bottom: 8px;
}
.as-rail-event .as-rail-event-time {
  font-size: 11px;
  color: var(--as-text-3);
  display: block;
}

.as-conversation {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 60px);
  max-height: calc(100vh - 60px);
  position: relative;
}

.as-history {
  flex: 1;
  overflow-y: auto;
  padding: 32px 24px 180px;
}
.as-history-inner {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.msg {
  display: flex;
  flex-direction: column;
  animation: as-fade-up var(--as-dur-slow) var(--as-ease-out) both;
}
.msg-user {
  align-items: flex-end;
}
.msg-user .msg-bubble {
  background: var(--as-text);
  color: var(--as-bg);
  border-radius: 20px 20px 4px 20px;
  padding: 12px 16px;
  max-width: 75%;
  font-size: 15px;
  line-height: 1.5;
}
.msg-assistant {
  align-items: flex-start;
}
.msg-assistant .msg-bubble {
  font-size: 16px;
  line-height: 1.6;
  color: var(--as-text);
  max-width: 100%;
  padding: 0;
}
.msg-assistant .msg-meta {
  font-size: 12px;
  color: var(--as-text-3);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.msg-assistant .msg-meta::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--as-accent);
}

/* Draft card embedded in conversation */
.msg-draft-card {
  align-self: stretch;
  background: var(--as-surface);
  border: 1px solid var(--as-line);
  border-radius: var(--as-r-md);
  padding: 0;
  overflow: hidden;
  margin-top: 4px;
  animation: as-fade-up var(--as-dur-slow) var(--as-ease-out) both;
}
.msg-draft-card .draft-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--as-line);
  background: var(--as-surface-2);
  font-size: 13px;
  color: var(--as-text-2);
}
.msg-draft-card .draft-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--as-r-full);
  background: var(--as-accent-soft);
  color: var(--as-accent);
  letter-spacing: 0.02em;
}
.msg-draft-card .draft-body {
  padding: 18px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--as-text);
  white-space: pre-wrap;
}
.msg-draft-card .draft-actions {
  display: flex;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--as-line);
  background: var(--as-surface);
}

.as-suggest-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}
.as-suggest {
  font-size: 14px;
  padding: 10px 16px;
  background: var(--as-surface);
  border: 1px solid var(--as-line);
  border-radius: var(--as-r-full);
  color: var(--as-text-2);
  cursor: pointer;
  transition: all var(--as-dur) var(--as-ease);
}
.as-suggest:hover { border-color: var(--as-accent); color: var(--as-accent); }

/* ============================================================
 * Composer
 * ============================================================ */

.composer-wrap {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 16px 24px 24px;
  background: linear-gradient(to bottom, transparent, var(--as-bg) 30%);
  z-index: 5;
}
.composer {
  max-width: 720px;
  margin: 0 auto;
  background: var(--as-surface);
  border: 1px solid var(--as-line-strong);
  border-radius: 22px;
  padding: 10px 10px 10px 12px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  box-shadow: var(--as-shadow-2);
  transition: border-color var(--as-dur) var(--as-ease), box-shadow var(--as-dur) var(--as-ease);
}
.composer:focus-within {
  border-color: var(--as-accent);
  box-shadow: var(--as-shadow-2), 0 0 0 4px var(--as-accent-ring);
}
.composer-textarea {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  resize: none;
  font-size: 16px;
  line-height: 1.45;
  color: var(--as-text);
  padding: 8px 4px;
  max-height: 180px;
  overflow-y: auto;
}
.composer-textarea::placeholder { color: var(--as-text-3); }
.composer-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--as-text);
  color: var(--as-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--as-dur) var(--as-ease), transform var(--as-dur) var(--as-ease-spring);
}
.composer-send:disabled { opacity: 0.35; cursor: not-allowed; }
.composer-send:not(:disabled):hover { background: var(--as-accent); color: var(--as-text-on-accent); }
.composer-send:not(:disabled):active { transform: scale(0.93); }
.composer-hint {
  font-size: 11px;
  color: var(--as-text-3);
  text-align: center;
  margin-top: 8px;
}
.composer-hint kbd {
  font-family: var(--as-font-mono);
  background: var(--as-surface-2);
  border: 1px solid var(--as-line);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 10px;
}

/* Slash palette */
.slash-palette {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  right: 0;
  max-width: 720px;
  margin: 0 auto;
  background: var(--as-surface);
  border: 1px solid var(--as-line);
  border-radius: var(--as-r-md);
  box-shadow: var(--as-shadow-3);
  padding: 6px;
  z-index: 10;
  display: none;
}
.slash-palette.open { display: block; animation: as-slide-up var(--as-dur) var(--as-ease-out); }
.slash-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--as-r-sm);
  font-size: 14px;
  color: var(--as-text);
  cursor: pointer;
  transition: background var(--as-dur-fast) var(--as-ease);
}
.slash-item:hover, .slash-item.active { background: var(--as-surface-2); }
.slash-item .slash-key {
  font-family: var(--as-font-mono);
  font-size: 12px;
  color: var(--as-accent);
}
.slash-item .slash-desc {
  margin-left: auto;
  font-size: 12px;
  color: var(--as-text-3);
}

/* Empty state */
.as-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 80px 24px;
  flex: 1;
}
.as-empty-greeting {
  font-family: var(--as-font-serif);
  font-size: 32px;
  font-weight: 500;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
}
.as-empty-sub {
  font-size: 16px;
  color: var(--as-text-2);
  max-width: 480px;
  margin: 0 auto 24px;
}

/* ============================================================
 * Activity / Drafts / Contacts list rows
 * ============================================================ */

.as-list {
  display: flex;
  flex-direction: column;
  background: var(--as-surface);
  border: 1px solid var(--as-line);
  border-radius: var(--as-r-md);
  overflow: hidden;
}
.as-list-row {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--as-line);
  transition: background var(--as-dur) var(--as-ease);
  cursor: pointer;
}
.as-list-row:last-child { border-bottom: none; }
.as-list-row:hover { background: var(--as-surface-2); }

.as-list-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--as-r-sm);
  background: var(--as-surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--as-text-2);
  flex-shrink: 0;
}
.as-list-icon.icon-call { color: var(--as-accent); background: var(--as-accent-soft); }
.as-list-icon.icon-email { color: #6366f1; background: rgba(99,102,241,0.10); }
.as-list-icon.icon-calendar { color: #b45309; background: rgba(180,83,9,0.10); }

.as-list-main { flex: 1; min-width: 0; }
.as-list-title { font-size: 15px; font-weight: 500; color: var(--as-text); }
.as-list-sub { font-size: 13px; color: var(--as-text-2); margin-top: 2px; line-height: 1.5; }
.as-list-time { font-size: 12px; color: var(--as-text-3); white-space: nowrap; }

.as-day-divider {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--as-text-3);
  padding: 24px 0 8px;
}

/* ============================================================
 * Animations
 * ============================================================ */

@keyframes as-fade-up {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes as-slide-up {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes as-shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
@keyframes as-orb-rotate {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
@keyframes as-orb-pulse {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50%      { transform: scale(1.08); opacity: 1; }
}

.as-fade-in { animation: as-fade-up var(--as-dur-slow) var(--as-ease-out) both; }

.as-typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}
.as-typing span {
  width: 6px;
  height: 6px;
  background: var(--as-text-3);
  border-radius: 50%;
  animation: as-typing-dot 1.2s ease-in-out infinite;
}
.as-typing span:nth-child(2) { animation-delay: 0.15s; }
.as-typing span:nth-child(3) { animation-delay: 0.30s; }
@keyframes as-typing-dot {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* ============================================================
 * Marketing
 * ============================================================ */

.as-hero {
  padding: 80px 24px 60px;
  max-width: 1100px;
  margin: 0 auto;
  text-align: center;
}
.as-hero .as-h1 { margin-bottom: 24px; }
.as-hero .as-lead { max-width: 600px; margin: 0 auto 36px; }
.as-cta-row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.as-feature-grid {
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 24px 80px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 28px;
}
@media (max-width: 768px) {
  .as-feature-grid { grid-template-columns: 1fr; }
}
.as-feature {
  padding: 28px;
  background: var(--as-surface);
  border: 1px solid var(--as-line);
  border-radius: var(--as-r-md);
}
.as-feature-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--as-r-sm);
  background: var(--as-accent-soft);
  color: var(--as-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}
.as-feature h3 {
  font-family: var(--as-font-serif);
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: 0 0 6px;
}
.as-feature p {
  font-size: 14px;
  color: var(--as-text-2);
  margin: 0;
  line-height: 1.55;
}

.as-demo {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 24px 80px;
}
.as-demo-window {
  background: var(--as-surface);
  border: 1px solid var(--as-line);
  border-radius: var(--as-r-lg);
  box-shadow: var(--as-shadow-3);
  overflow: hidden;
}
.as-demo-chrome {
  display: flex;
  gap: 6px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--as-line);
}
.as-demo-chrome span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--as-line-strong);
}
.as-demo-body {
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  font-size: 15px;
  min-height: 240px;
}
.as-demo-line {
  opacity: 0;
  animation: as-fade-up 0.6s var(--as-ease-out) forwards;
}
.as-demo-line.user {
  align-self: flex-end;
  background: var(--as-text);
  color: var(--as-bg);
  padding: 10px 14px;
  border-radius: 18px 18px 4px 18px;
  max-width: 75%;
}
.as-demo-line.assistant {
  align-self: flex-start;
  color: var(--as-text);
  max-width: 85%;
}
.as-demo-line.assistant::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--as-accent);
  margin-right: 8px;
  vertical-align: middle;
}

/* ============================================================
 * Pricing
 * ============================================================ */

.as-pricing-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}
@media (max-width: 1024px) {
  .as-pricing-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .as-pricing-grid { grid-template-columns: 1fr; }
}
.as-plan {
  position: relative;
  background: var(--as-surface);
  border: 1px solid var(--as-line);
  border-radius: var(--as-r-lg);
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
}
.as-plan-popular {
  border-color: var(--as-accent);
  box-shadow: 0 0 0 1px var(--as-accent), var(--as-shadow-2);
  transform: translateY(-8px);
}
.as-plan-badge {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--as-accent);
  color: var(--as-text-on-accent);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: var(--as-r-full);
}
.as-plan-name {
  font-family: var(--as-font-serif);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.015em;
  margin-bottom: 4px;
}
.as-plan-price {
  font-family: var(--as-font-serif);
  font-size: 40px;
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1;
  margin-bottom: 4px;
}
.as-plan-price span {
  font-family: var(--as-font-sans);
  font-size: 14px;
  font-weight: 400;
  color: var(--as-text-3);
  letter-spacing: 0;
}
.as-plan-desc {
  font-size: 13px;
  color: var(--as-text-2);
  margin-bottom: 22px;
  min-height: 36px;
}
.as-plan-features {
  list-style: none;
  padding: 0;
  margin: 0 0 22px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  font-size: 14px;
  color: var(--as-text-2);
}
.as-plan-features li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  line-height: 1.45;
}
.as-plan-features li::before {
  content: '✓';
  color: var(--as-accent);
  font-weight: 600;
  flex-shrink: 0;
}
.as-plan .as-btn { margin-top: auto; width: 100%; }

/* ============================================================
 * Onboarding
 * ============================================================ */

.as-onboard-shell {
  max-width: 560px;
  margin: 0 auto;
  padding: 60px 24px 80px;
}
.as-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 40px;
  justify-content: center;
}
.as-progress-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--as-line-strong);
  transition: all var(--as-dur) var(--as-ease);
}
.as-progress-dot.active {
  background: var(--as-accent);
  width: 24px;
  border-radius: var(--as-r-full);
}
.as-progress-dot.done { background: var(--as-accent); }

.as-onboard-step { display: none; animation: as-fade-up var(--as-dur-slow) var(--as-ease-out); }
.as-onboard-step.active { display: block; }
.as-onboard-step h2 {
  font-family: var(--as-font-serif);
  font-size: 32px;
  font-weight: 500;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
}
.as-onboard-step .as-onboard-sub {
  font-size: 16px;
  color: var(--as-text-2);
  margin-bottom: 32px;
}
.as-onboard-actions {
  display: flex;
  justify-content: space-between;
  margin-top: 40px;
}

.as-toggle-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 18px;
  background: var(--as-surface);
  border: 1px solid var(--as-line);
  border-radius: var(--as-r-md);
  cursor: pointer;
  margin-bottom: 12px;
  transition: all var(--as-dur) var(--as-ease);
}
.as-toggle-card:hover { border-color: var(--as-line-strong); }
.as-toggle-card.on {
  border-color: var(--as-accent);
  background: var(--as-accent-soft);
}
.as-toggle-card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--as-r-sm);
  background: var(--as-surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--as-text-2);
  flex-shrink: 0;
}
.as-toggle-card.on .as-toggle-card-icon {
  background: var(--as-accent);
  color: var(--as-text-on-accent);
}
.as-toggle-card h4 {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 600;
}
.as-toggle-card p {
  margin: 0;
  font-size: 13px;
  color: var(--as-text-2);
  line-height: 1.5;
}

/* OAuth buttons */
.as-oauth-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  height: 52px;
  background: var(--as-surface);
  border: 1px solid var(--as-line-strong);
  border-radius: var(--as-r-sm);
  font-size: 15px;
  font-weight: 500;
  color: var(--as-text);
  margin-bottom: 12px;
  transition: all var(--as-dur) var(--as-ease);
  position: relative;
}
.as-oauth-btn:hover:not(:disabled) {
  border-color: var(--as-text);
  background: var(--as-surface-2);
}
.as-oauth-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.as-oauth-btn svg { width: 20px; height: 20px; flex-shrink: 0; }

/* ============================================================
 * Voice orb (reused styling cue from .va-orb)
 * ============================================================ */

.as-orb {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, var(--as-accent), var(--as-accent-2));
  position: relative;
  margin: 0 auto;
  box-shadow: 0 0 32px var(--as-accent-ring);
}
.as-orb::before {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 1px solid var(--as-accent-ring);
  animation: as-orb-pulse 2s ease-in-out infinite;
}
.as-orb-mini {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, var(--as-accent), var(--as-accent-2));
  display: inline-block;
  vertical-align: middle;
}

/* ============================================================
 * Utility
 * ============================================================ */

.as-container { max-width: 1100px; margin: 0 auto; padding: 0 24px; }
.as-container-narrow { max-width: 720px; margin: 0 auto; padding: 0 24px; }
.as-stack { display: flex; flex-direction: column; gap: 16px; }
.as-stack-lg { display: flex; flex-direction: column; gap: 28px; }
.as-row { display: flex; align-items: center; gap: 12px; }
.as-row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.as-spacer { flex: 1; }
.as-divider { height: 1px; background: var(--as-line); margin: 16px 0; }

.as-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  background: var(--as-surface-2);
  border-radius: var(--as-r-full);
  font-size: 12px;
  color: var(--as-text-2);
}
.as-pill-good { background: rgba(4,120,87,0.10); color: var(--as-good); }
.as-pill-warn { background: rgba(180,83,9,0.10); color: var(--as-warn); }
.as-pill-bad  { background: rgba(185,28,28,0.10); color: var(--as-bad); }

.as-meter {
  height: 6px;
  background: var(--as-surface-2);
  border-radius: var(--as-r-full);
  overflow: hidden;
}
.as-meter-fill {
  height: 100%;
  background: var(--as-accent);
  border-radius: var(--as-r-full);
  transition: width var(--as-dur-slow) var(--as-ease-out);
}

/* Modal */
.as-modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--as-overlay);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: as-fade-up var(--as-dur) var(--as-ease-out);
}
.as-modal {
  background: var(--as-surface);
  border-radius: var(--as-r-lg);
  padding: 28px;
  max-width: 480px;
  width: 100%;
  box-shadow: var(--as-shadow-3);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================================
 * Text-first assistant — pa.hiroi.ai (text.html) and /join (join.html)
 * One idea per screen: a number to text, then one decision.
 * ============================================================ */

.tx-hero {
  max-width: 760px;
  margin: 0 auto;
  padding: 112px 24px 64px;
  text-align: center;
}
.tx-title {
  margin: 0;
  font-size: clamp(46px, 8.4vw, 92px);
  font-weight: 600;
  line-height: 0.98;
  letter-spacing: -0.045em;
  color: var(--as-text);
}
.tx-lead {
  max-width: 30ch;
  margin: 28px auto 0;
  font-size: clamp(18px, 2.2vw, 21px);
  line-height: 1.45;
  letter-spacing: -0.01em;
  color: var(--as-text-2);
}
.tx-cta { margin-top: 44px; }
.tx-cta-btn {
  min-width: 260px;
  font-variant-numeric: tabular-nums;
}
.tx-terms {
  margin: 14px 0 0;
  font-size: 14px;
  color: var(--as-text-2);
}

.tx-demo {
  max-width: 420px;
  margin: 0 auto;
  padding: 0 24px 104px;
}
.tx-thread {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 22px 18px;
  background: var(--as-surface);
  border: 1px solid var(--as-line);
  border-radius: var(--as-r-xl);
  box-shadow: var(--as-shadow-3);
}
.tx-bubble {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 20px;
  font-size: 15px;
  line-height: 1.4;
  opacity: 0;
  animation: as-fade-up 0.5s var(--as-ease-out) forwards;
}
.tx-bubble:nth-child(1) { animation-delay: 300ms; }
.tx-bubble:nth-child(2) { animation-delay: 900ms; }
.tx-bubble:nth-child(3) { animation-delay: 1500ms; }
.tx-you {
  align-self: flex-end;
  background: var(--as-text);
  color: var(--as-bg);
  border-bottom-right-radius: 6px;
}
.tx-hiroi {
  align-self: flex-start;
  background: var(--as-surface-2);
  color: var(--as-text);
  border-bottom-left-radius: 6px;
}

.tx-steps {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 24px 96px;
}
.tx-steps ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 40px;
}
.tx-steps li {
  padding-top: 20px;
  border-top: 1px solid var(--as-line-strong);
}
.tx-step-n {
  font-family: var(--as-font-mono);
  font-size: 13px;
  color: var(--as-text-2);
}
.tx-steps h2 {
  margin: 10px 0 6px;
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.tx-steps p {
  margin: 0;
  font-size: 15px;
  line-height: 1.55;
  color: var(--as-text-2);
}
@media (max-width: 720px) {
  .tx-hero { padding-top: 80px; }
  .tx-steps ol { grid-template-columns: 1fr; gap: 28px; }
}

.tx-close {
  padding: 0 24px 72px;
  text-align: center;
  font-size: 14px;
  color: var(--as-text-2);
}
.tx-close p { margin: 0; }
.tx-close a,
.tx-fine a,
.tx-num {
  color: var(--as-text);
  text-decoration: underline;
  text-decoration-color: var(--as-line-strong);
  text-underline-offset: 3px;
}
.tx-close a:hover,
.tx-fine a:hover,
.tx-num:hover { text-decoration-color: currentColor; }

/* /join */
.tx-panel {
  max-width: 420px;
  margin: 0 auto;
  padding: 80px 24px 64px;
  text-align: center;
}
.tx-mark {
  width: 56px;
  height: 56px;
  margin: 0 auto 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  background: var(--as-text);
  color: var(--as-bg);
}
.tx-mark svg { width: 26px; height: 26px; }
.tx-mark--done {
  border-radius: 50%;
  background: var(--teal-fill, var(--as-accent));
  color: #fff;
}
/* The text pages share hiroi.ai's green, not the older assistant teal. */
[data-page="text"] .as-btn-primary:hover:not(:disabled),
[data-page="join"] .as-btn-primary:hover:not(:disabled),
[data-page^="app-"] .as-btn-primary:hover:not(:disabled) {
  background: var(--teal-fill, var(--as-accent));
  color: #fff;
}
.tx-panel-title {
  margin: 0;
  font-size: clamp(28px, 6vw, 34px);
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -0.035em;
}
.tx-panel-sub {
  margin: 10px 0 0;
  font-size: 16px;
  color: var(--as-text-2);
}
.tx-summary {
  margin: 36px 0 28px;
  padding: 0;
  text-align: left;
  border-top: 1px solid var(--as-line);
}
.tx-summary div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 2px;
  border-bottom: 1px solid var(--as-line);
  font-size: 15px;
}
.tx-summary dt { color: var(--as-text-2); }
.tx-summary dd {
  margin: 0;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--as-text);
}
.tx-form { margin: 0; }
.tx-panel-sub + .tx-form,
.tx-panel-sub + .tx-alert { margin-top: 36px; }
.tx-wide { width: 100%; }
.tx-note {
  margin: 14px 0 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--as-text-2);
}
.tx-alert {
  margin: 0 0 14px;
  font-size: 14px;
  color: var(--as-bad);
}
.tx-fine {
  margin: 40px 0 0;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--as-text-2);
}

/* Narrow phones: the shared nav's three CTAs crowd the wordmark. Pricing goes first. */
@media (max-width: 480px) {
  body:not([data-page="text"]) .as-nav-cta .as-btn-ghost:first-child { display: none; }
  .as-nav-cta { gap: 4px; }
}
@media (prefers-color-scheme: dark) {
  :root:not([data-as-theme="light"]) .tx-alert { color: #f87171; }
}

/* ═══════════════════════════════════════════════════════════════════════
 * Hiroi web app — pa.hiroi.ai (app_signin / app_trial / app_chat)
 * ═══════════════════════════════════════════════════════════════════════ */

.app-auth { text-align: left; }
.app-auth .tx-panel-title,
.app-auth .tx-panel-sub { text-align: center; }
.app-auth .tx-panel-sub { margin-bottom: 32px; }
.app-step { display: flex; flex-direction: column; gap: 10px; }
.app-step[hidden] { display: none; }
.app-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--as-text-2);
}
.app-input {
  width: 100%;
  min-height: 52px;
  padding: 0 16px;
  border: 1px solid var(--as-line-strong);
  border-radius: var(--as-r-md);
  background: var(--as-surface);
  color: var(--as-text);
  font: inherit;
  font-size: 17px;   /* ≥16px or iOS zooms the page on focus */
  margin-bottom: 6px;
}
.app-input::placeholder { color: var(--as-text-3); }
.app-input:focus-visible {
  outline: 2px solid var(--teal-fill, var(--as-accent));
  outline-offset: 2px;
  border-color: transparent;
}
.app-code {
  text-align: center;
  font-family: var(--as-font-mono);
  font-size: 26px;
  letter-spacing: 0.4em;
  padding-left: 0.4em;  /* balance the trailing letter-space */
}
.app-link {
  align-self: center;
  margin-top: 6px;
  padding: 10px 8px;
  border: 0;
  background: none;
  color: var(--as-text-2);
  font: inherit;
  font-size: 14px;
  text-decoration: underline;
  text-decoration-color: var(--as-line-strong);
  text-underline-offset: 3px;
  cursor: pointer;
}
.app-link:hover { color: var(--as-text); text-decoration-color: currentColor; }
.app-auth .tx-alert { margin: 14px 0 0; text-align: center; }
.app-auth .tx-fine,
.app-who { text-align: center; }
.app-who .app-link { display: inline; margin: 0; padding: 4px 2px; font-size: inherit; }
.app-or {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 28px 0;
  color: var(--as-text-3);
  font-size: 13px;
}
.app-or::before,
.app-or::after { content: ''; flex: 1; height: 1px; background: var(--as-line); }
.app-providers { display: flex; flex-direction: column; gap: 10px; }

.app-sheet {
  width: min(420px, calc(100vw - 32px));
  margin: auto;
  padding: 20px 20px 16px;
  border: 1px solid var(--as-line);
  border-radius: var(--as-r-lg);
  background: var(--as-surface);
  color: var(--as-text);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
}
.app-sheet::backdrop { background: var(--as-overlay); }
.app-sheet-head { display: flex; align-items: center; justify-content: space-between; }
.app-sheet-head h2 { margin: 0; font-size: 17px; font-weight: 600; }
.app-sheet-close {
  width: 44px;
  height: 44px;
  margin: -8px -8px -8px 0;
  border: 0;
  background: none;
  color: var(--as-text-2);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}
.app-sheet-close:focus-visible {
  outline: 2px solid var(--teal-fill, var(--as-accent));
  outline-offset: -4px;
  border-radius: var(--as-r-sm);
}
.app-sheet-email { margin: 12px 0 2px; font-weight: 500; word-break: break-all; }
.app-sheet-plan { margin: 0 0 18px; font-size: 14px; color: var(--as-text-2); }
.app-sheet form { margin: 0 0 8px; }
@media (max-width: 640px) {
  /* A bottom sheet on phones: thumb-reachable, and it reads as part of the app. */
  .app-sheet {
    width: 100%;
    max-width: none;
    margin: auto 0 0;
    border-radius: var(--as-r-lg) var(--as-r-lg) 0 0;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }
}
/* The canvas wears the app's ground too, so no white shows past short content. */
html:has(body[data-page^="app-"]) { background: var(--as-bg); }

/* ═══════════════════════════════════════════════════════════════════════
 * Hiroi chat (app_chat.html + static/js/pa-app/chat.js) — prefix pc-
 * Phone first. The app is pinned to the VISUAL viewport (--pc-vh/--pc-vt,
 * set by chat.js) so the composer stays above the iOS keyboard.
 * ═══════════════════════════════════════════════════════════════════════ */

body[data-page="app-chat"] {
  margin: 0;
  background: var(--as-bg);
  color: var(--as-text);
  font-family: var(--as-font-sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
.pc-sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.pc-app {
  position: fixed;
  left: 0; right: 0;
  top: var(--pc-vt, 0px);
  height: var(--pc-vh, 100dvh);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

/* ---- icons & icon buttons -------------------------------------------- */
.pc-icon-btn svg,
.pc-new svg,
.pc-send svg {
  width: 22px; height: 22px;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}
.pc-icon-btn {
  width: 44px; height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 12px;
  background: none; color: var(--as-text);
  cursor: pointer;
}
.pc-icon-btn:hover { background: var(--as-surface-hover); }
.pc-icon-btn:focus-visible,
.pc-new:focus-visible,
.pc-convo:focus-visible,
.pc-me:focus-visible,
.pc-chip:focus-visible,
.pc-retry:focus-visible,
.pc-send:focus-visible {
  outline: 2px solid var(--teal-fill, var(--as-accent));
  outline-offset: 2px;
}

/* ---- main column ------------------------------------------------------ */
.pc-main {
  display: flex; flex-direction: column;
  min-height: 0; min-width: 0;
  height: 100%;
}
.pc-bar {
  flex: none;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 4px;
  padding: calc(env(safe-area-inset-top, 0px) + 6px) 8px 6px;
  border-bottom: 1px solid var(--as-line);
}
.pc-title {
  margin: 0;
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pc-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  /* WCAG 2.4.11: nothing focused may hide behind the composer. */
  scroll-padding-bottom: 24px;
}
.pc-log,
.pc-empty {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 20px 28px;
}

/* ---- empty state ------------------------------------------------------ */
.pc-empty { padding-top: clamp(32px, 10vh, 96px); }
.pc-empty[hidden] { display: none; }
.pc-empty-hi {
  margin: 0 0 6px;
  font-size: clamp(26px, 6vw, 34px);
  line-height: 1.12;
  font-weight: 650;
  letter-spacing: -0.025em;
}
.pc-empty-sub {
  margin: 0 0 28px;
  font-size: 18px;
  color: var(--as-text-2);
}
.pc-suggest { display: grid; gap: 10px; }
@media (min-width: 560px) { .pc-suggest { grid-template-columns: 1fr 1fr; } }
.pc-chip {
  min-height: 52px;
  padding: 14px 16px;
  border: 1px solid var(--as-line-strong);
  border-radius: var(--as-r-md);
  background: var(--as-surface);
  color: var(--as-text);
  font: inherit; font-size: 15px; line-height: 1.4;
  text-align: left;
  cursor: pointer;
  transition: background var(--as-dur-fast) var(--as-ease), border-color var(--as-dur-fast) var(--as-ease);
}
.pc-chip:hover { background: var(--as-surface-hover); border-color: var(--as-text-3); }

/* ---- messages --------------------------------------------------------- */
.pc-msg { display: flex; }
.pc-msg + .pc-msg { margin-top: 22px; }
.pc-msg--user { justify-content: flex-end; }
.pc-msg--user .pc-body {
  max-width: min(85%, 560px);
  padding: 10px 15px;
  border-radius: 20px 20px 6px 20px;
  background: var(--teal-fill, var(--as-accent));
  color: var(--teal-on, #fff);
  font-size: 16px; line-height: 1.5;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.pc-msg--assistant .pc-body {
  min-width: 0; max-width: 100%;
  font-size: 16.5px; line-height: 1.62;
  overflow-wrap: anywhere;
}
.pc-body > :first-child { margin-top: 0; }
.pc-body > :last-child { margin-bottom: 0; }
.pc-msg--assistant .pc-body p { margin: 0 0 12px; }
.pc-msg--assistant .pc-body ul,
.pc-msg--assistant .pc-body ol { margin: 0 0 12px; padding-left: 1.3em; }
.pc-msg--assistant .pc-body li + li { margin-top: 4px; }
.pc-msg--assistant .pc-body h1,
.pc-msg--assistant .pc-body h2,
.pc-msg--assistant .pc-body h3 { margin: 18px 0 8px; font-size: 17px; font-weight: 650; }
.pc-msg--assistant .pc-body a {
  color: var(--as-text);
  text-decoration: underline; text-decoration-color: var(--as-line-strong); text-underline-offset: 3px;
}
.pc-msg--assistant .pc-body code {
  font-family: var(--as-font-mono); font-size: 0.9em;
  padding: 1px 5px; border-radius: 6px; background: var(--as-surface-hover);
}
.pc-msg--assistant .pc-body pre {
  margin: 0 0 12px; padding: 12px 14px;
  border-radius: var(--as-r-sm); background: var(--as-surface-hover);
  overflow-x: auto;
}
.pc-msg--assistant .pc-body pre code { padding: 0; background: none; }
.pc-msg--assistant .pc-body blockquote {
  margin: 0 0 12px; padding-left: 12px; border-left: 2px solid var(--as-line-strong); color: var(--as-text-2);
}
.pc-msg--assistant .pc-body table { display: block; overflow-x: auto; border-collapse: collapse; margin: 0 0 12px; }
.pc-msg--assistant .pc-body th,
.pc-msg--assistant .pc-body td { padding: 6px 10px; border-bottom: 1px solid var(--as-line); text-align: left; }

.pc-status {
  display: flex; align-items: center; gap: 10px;
  margin: 0; color: var(--as-text-2); font-size: 15px;
}
.pc-dots { display: inline-flex; gap: 4px; }
.pc-dots i {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--as-text-3);
  animation: pc-dot 1.2s var(--as-ease) infinite;
}
.pc-dots i:nth-child(2) { animation-delay: 0.15s; }
.pc-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes pc-dot { 0%, 60%, 100% { opacity: 0.3; transform: none; } 30% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .pc-dots i { animation: none; opacity: 0.6; } }

.pc-err { margin: 0; color: var(--as-bad); font-size: 15px; }
.pc-retry {
  margin-left: 4px; padding: 6px 4px;
  border: 0; background: none;
  color: var(--as-text); font: inherit; font-weight: 500;
  text-decoration: underline; text-underline-offset: 3px;
  cursor: pointer;
}
.pc-stopped { margin: 8px 0 0; font-size: 13px; color: var(--as-text-3); }

/* ---- composer --------------------------------------------------------- */
.pc-composer {
  flex: none;
  display: flex; align-items: flex-end; gap: 8px;
  width: calc(100% - 24px);
  max-width: 720px;
  margin: 0 auto;
  padding: 6px 6px 6px 16px;
  border: 1px solid var(--as-line-strong);
  border-radius: 26px;
  background: var(--as-surface);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.05);
}
.pc-composer:focus-within { border-color: var(--teal-fill, var(--as-accent)); }
.pc-input {
  flex: 1 1 auto;
  min-width: 0;
  max-height: 168px;
  margin: 0;
  padding: 9px 0;
  border: 0; outline: 0;
  background: transparent;
  color: var(--as-text);
  font: inherit;
  font-size: 17px;     /* ≥16px or iOS zooms the page on focus */
  line-height: 1.45;
  resize: none;
}
.pc-input::placeholder { color: var(--as-text-3); }
.pc-send {
  flex: none;
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 50%;
  background: var(--teal-fill, var(--as-accent));
  color: var(--teal-on, #fff);
  cursor: pointer;
  transition: background var(--as-dur-fast) var(--as-ease), opacity var(--as-dur-fast) var(--as-ease);
}
.pc-send:disabled { background: var(--as-line-strong); color: var(--as-surface); cursor: default; }
.pc-send .pc-i-stop { display: none; }
.pc-app.is-busy .pc-send .pc-i-send { display: none; }
.pc-app.is-busy .pc-send .pc-i-stop { display: block; fill: currentColor; stroke: none; }
.pc-mic { flex: none; width: 40px; height: 40px; border-radius: 50%; color: var(--as-text-2); }
.pc-mic[hidden], .pc-composer[hidden] { display: none; }
.pc-mic:hover { color: var(--as-text); }

/* ---- voice ------------------------------------------------------------ */
/* Takes the composer's place while talking. The orb follows the mic level
   (--pc-level, 0–1, set by chat.js) and the state chat.js puts on data-state. */
.pc-voice {
  flex: none;
  display: flex; align-items: center; gap: 14px;
  width: calc(100% - 24px);
  max-width: 720px;
  min-height: 64px;
  margin: 0 auto;
  padding: 10px 10px 10px 14px;
  border: 1px solid var(--as-line-strong);
  border-radius: 32px;
  background: var(--as-surface);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.05);
}
.pc-voice[hidden] { display: none; }
.pc-voice-orb {
  flex: none;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--teal-fill, var(--as-accent));
  opacity: 0.35;
  transform: scale(calc(0.82 + var(--pc-level, 0) * 0.3));
  transition: transform 90ms linear, opacity var(--as-dur) var(--as-ease);
}
.pc-voice[data-state="listening"] .pc-voice-orb,
.pc-voice[data-state="hearing"] .pc-voice-orb { opacity: 1; }
.pc-voice[data-state="thinking"] .pc-voice-orb { opacity: 0.6; animation: pc-breathe 1.4s var(--as-ease) infinite; }
.pc-voice[data-state="speaking"] .pc-voice-orb { opacity: 1; animation: pc-breathe 0.9s var(--as-ease) infinite; }
@keyframes pc-breathe { 50% { transform: scale(1.08); } }
.pc-voice-text { flex: 1 1 auto; min-width: 0; }
.pc-voice-status { margin: 0; font-size: 16px; font-weight: 550; }
.pc-voice-hint { margin: 2px 0 0; font-size: 13px; color: var(--as-text-3); }
.pc-voice-end {
  flex: none;
  min-width: 64px; min-height: 44px; padding: 0 18px;
  border: 0; border-radius: 22px;
  background: var(--as-text); color: var(--as-bg);
  font: inherit; font-size: 15px; font-weight: 550;
  cursor: pointer;
}
.pc-voice-end:focus-visible { outline: 2px solid var(--teal-fill, var(--as-accent)); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  .pc-voice-orb { transition: none; transform: none; animation: none !important; }
}
.pc-note {
  margin: 22px 0 0;
  font-size: 14px; line-height: 1.5;
  color: var(--as-text-2);
  text-align: center;
}
.pc-note + .pc-msg { margin-top: 22px; }

.pc-disclaim {
  flex: none;
  margin: 6px 0 0;
  padding: 0 16px calc(env(safe-area-inset-bottom, 0px) + 8px);
  text-align: center;
  font-size: 12px;
  color: var(--as-text-3);
}

/* ---- conversations ---------------------------------------------------- */
.pc-side {
  position: fixed;
  z-index: 20;
  top: 0; bottom: 0; left: 0;
  width: min(84vw, 320px);
  display: flex; flex-direction: column;
  padding: calc(env(safe-area-inset-top, 0px) + 8px) 12px calc(env(safe-area-inset-bottom, 0px) + 12px);
  background: var(--as-surface);
  border-right: 1px solid var(--as-line);
  transform: translateX(-100%);
  visibility: hidden;
  transition: transform var(--as-dur) var(--as-ease-out), visibility 0s linear var(--as-dur);
}
.pc-app.is-side-open .pc-side {
  transform: none; visibility: visible;
  transition: transform var(--as-dur) var(--as-ease-out);
}
.pc-scrim {
  position: fixed; inset: 0; z-index: 15;
  background: var(--as-overlay);
}
.pc-scrim[hidden] { display: none; }
.pc-side-head { display: flex; align-items: center; justify-content: space-between; padding: 0 4px 0 8px; height: 44px; }
.pc-wordmark { font-size: 15px; font-weight: 600; letter-spacing: 0.06em; color: var(--as-text-2); }
.pc-new {
  display: flex; align-items: center; gap: 10px;
  margin: 10px 0 14px;
  min-height: 44px; padding: 0 12px;
  border: 1px solid var(--as-line-strong); border-radius: var(--as-r-sm);
  background: none; color: var(--as-text);
  font: inherit; font-size: 15px; font-weight: 500;
  cursor: pointer;
}
.pc-new:hover { background: var(--as-surface-hover); }
.pc-convos { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.pc-convo {
  display: block; width: 100%;
  min-height: 40px; padding: 9px 12px;
  border: 0; border-radius: var(--as-r-xs);
  background: none; color: var(--as-text);
  font: inherit; font-size: 14.5px; text-align: left;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  cursor: pointer;
}
.pc-convo:hover { background: var(--as-surface-hover); }
.pc-convo[aria-current="true"] { background: var(--as-surface-hover); font-weight: 500; }
.pc-convos-empty { margin: 8px 12px; font-size: 14px; color: var(--as-text-3); }
.pc-side-foot { flex: none; padding-top: 10px; border-top: 1px solid var(--as-line); }
.pc-me {
  display: flex; align-items: center; gap: 10px;
  width: 100%; min-height: 48px; padding: 6px 8px;
  border: 0; border-radius: var(--as-r-sm);
  background: none; color: var(--as-text);
  font: inherit; font-size: 14px; text-align: left;
  cursor: pointer;
}
.pc-me:hover { background: var(--as-surface-hover); }
.pc-avatar {
  flex: none;
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--as-text); color: var(--as-bg);
  font-weight: 600; font-size: 13px;
}
.pc-me-email { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Wide screens: the conversations are a column, always there. */
@media (min-width: 960px) {
  .pc-app { grid-template-columns: 280px minmax(0, 1fr); }
  .pc-side {
    position: static;
    width: auto;
    transform: none; visibility: visible; transition: none;
    background: var(--as-bg);
  }
  .pc-scrim, .pc-side-close { display: none !important; }
  /* Keep the menu's slot so the title stays centred and New chat stays right. */
  .pc-menu { visibility: hidden; }
}
@media (prefers-reduced-motion: reduce) {
  .pc-side, .pc-app.is-side-open .pc-side { transition: none; }
}
/* Focusable so a keyboard user can scroll it (axe scrollable-region-focusable);
   the ring is drawn inside so it never clips against the composer. */
.pc-scroll:focus-visible { outline: 2px solid var(--teal-fill, var(--as-accent)); outline-offset: -2px; }
