:root {
  --bg: #05070d;
  --bg-panel: rgba(8, 20, 32, 0.55);
  --line: rgba(59, 232, 255, 0.35);
  --line-strong: rgba(59, 232, 255, 0.85);
  --cyan: #3be8ff;
  --cyan-dim: #7aa9b8;
  --orange: #ffb547;
  --red: #ff5d6c;
  --green: #4dffa6;
  --text: #dff8ff;
  --text-dim: #7d9aa6;
  --font: "Hiragino Sans", "Hiragino Kaku Gothic ProN", system-ui, -apple-system, sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, monospace;
  --gutter: max(16px, env(safe-area-inset-left));
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.grid-bg {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(ellipse at center, rgba(20, 90, 120, 0.25), transparent 65%),
    linear-gradient(rgba(59, 232, 255, 0.05) 1px, transparent 1px) 0 0 / 40px 40px,
    linear-gradient(90deg, rgba(59, 232, 255, 0.05) 1px, transparent 1px) 0 0 / 40px 40px;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) var(--gutter) 10px;
  border-bottom: 1px solid var(--line);
  font-family: var(--mono); font-size: 13px; letter-spacing: 0.15em;
  color: var(--cyan);
}
.brand { font-weight: 700; }
.corner { color: var(--orange); }
.clock { color: var(--text-dim); }
.status { display: flex; align-items: center; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); }
.dot.busy { background: var(--orange); box-shadow: 0 0 8px var(--orange); }

/* ---------- layout ---------- */
.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(320px, 1.6fr) minmax(220px, 1fr);
  gap: 16px;
  padding: 16px var(--gutter);
}
.col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.col-center { align-items: center; justify-content: center; }

/* ---------- panels ---------- */
.panel {
  position: relative;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  padding: 14px 16px;
  clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 14px, 100% 100%, 14px 100%, 0 calc(100% - 14px));
  transition: border-color 0.3s, box-shadow 0.3s;
}
.panel::before {
  content: ""; position: absolute; left: 0; top: 0; width: 40px; height: 2px; background: var(--cyan);
}
.panel.highlight { border-color: var(--line-strong); box-shadow: inset 0 0 24px rgba(59, 232, 255, 0.25); }
.panel h2 {
  font-size: 13px; font-weight: 600; letter-spacing: 0.08em;
  color: var(--cyan); margin-bottom: 8px;
}
.big {
  font-family: var(--mono); font-size: 34px; font-weight: 700; color: var(--text);
  text-shadow: 0 0 12px rgba(59, 232, 255, 0.6);
}
.sub { font-size: 13px; color: var(--text-dim); margin-top: 4px; }
.up { color: var(--green); }
.down { color: var(--red); }
.spark { width: 100%; height: 36px; margin-top: 8px; }
.spark polyline { fill: none; stroke: var(--cyan); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.spark circle { fill: var(--orange); }

.bar { height: 10px; border: 1px solid var(--line); margin-top: 4px; }
.bar-fill {
  height: 100%; width: 0;
  background: repeating-linear-gradient(90deg, var(--cyan) 0 8px, transparent 8px 10px);
  transition: width 1s ease;
}
.kv { display: flex; justify-content: space-between; font-size: 14px; padding: 3px 0; }
.kv span { color: var(--text-dim); }
.kv b { font-family: var(--mono); }

.list { list-style: none; font-size: 14px; }
.list li { display: flex; gap: 10px; padding: 6px 0; border-bottom: 1px dashed rgba(59, 232, 255, 0.15); }
.list li:last-child { border-bottom: 0; }
.list .t { font-family: var(--mono); color: var(--orange); min-width: 48px; }
.list .done { color: var(--text-dim); text-decoration: line-through; }
.list .due { margin-left: auto; color: var(--text-dim); font-size: 12px; }

/* ---------- orb ---------- */
.orb-wrap { position: relative; width: min(100%, 52vh, 460px); aspect-ratio: 1; }
#orb { width: 100%; height: 100%; display: block; }
.orb-label {
  position: absolute; left: 0; right: 0; bottom: 4%; text-align: center;
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.3em; color: var(--cyan-dim);
}
.transcript { width: 100%; max-width: 560px; text-align: center; min-height: 5.5em; }
.you { font-size: 14px; color: var(--text-dim); min-height: 1.4em; }
.you:not(:empty)::before { content: "YOU › "; font-family: var(--mono); color: var(--orange); }
.reply { font-size: 17px; line-height: 1.6; margin-top: 6px; -webkit-user-select: text; user-select: text; }

/* ---------- dock ---------- */
.dock {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 10px var(--gutter) calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  position: sticky; bottom: 0; z-index: 10;
  background: rgba(5, 7, 13, 0.92);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.talk {
  display: inline-flex; align-items: center; gap: 12px;
  padding: 14px 40px; min-height: 56px;
  background: rgba(59, 232, 255, 0.08);
  border: 1px solid var(--line-strong); color: var(--cyan);
  font-family: var(--mono); font-size: 16px; letter-spacing: 0.25em;
  border-radius: 999px; cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
}
.talk:active { background: rgba(59, 232, 255, 0.2); }
.talk-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 12px var(--cyan); }
.talk.listening { border-color: var(--orange); color: var(--orange); box-shadow: 0 0 24px rgba(255, 181, 71, 0.35); }
.talk.listening .talk-dot { background: var(--orange); box-shadow: 0 0 12px var(--orange); animation: pulse 0.8s infinite alternate; }
@keyframes pulse { to { transform: scale(1.4); opacity: 0.6; } }

.textbox { display: flex; gap: 8px; width: 100%; max-width: 560px; }
.textbox input {
  flex: 1; min-width: 0; padding: 10px 12px; font-size: 16px; /* 16px以上でiOSの自動ズームを防ぐ */
  background: rgba(0, 0, 0, 0.4); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; font-family: var(--font);
  -webkit-user-select: text; user-select: text;
}
.textbox input:focus { outline: none; border-color: var(--line-strong); }
.textbox button {
  padding: 0 16px; background: transparent; color: var(--cyan);
  border: 1px solid var(--line); border-radius: 8px; font-size: 14px; cursor: pointer;
}

/* ---------- portrait / narrow ---------- */
@media (max-width: 900px), (orientation: portrait) {
  .layout { grid-template-columns: 1fr 1fr; grid-template-areas: "center center" "left right"; }
  .col-center { grid-area: center; }
  .col-left { grid-area: left; }
  .col-right { grid-area: right; }
  .orb-wrap { width: min(100%, 38vh, 420px); }
}
@media (max-width: 560px) {
  .layout { grid-template-columns: 1fr; grid-template-areas: "center" "left" "right"; }
  .topbar { font-size: 11px; letter-spacing: 0.08em; }
  .clock { display: none; }
  .big { font-size: 28px; }
}
@media (prefers-reduced-motion: reduce) {
  .talk.listening .talk-dot { animation: none; }
}
