:root {
  color-scheme: light;
  --primary: #4338ca;
  --primary-hover: #3730a3;
  --primary-soft: #eef2ff;
  --accent: #15803d;
  --accent-soft: #ecfdf3;
  --warning: #a16207;
  --warning-soft: #fffbeb;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --ink: #172033;
  --muted-ink: #526077;
  --subtle-ink: #6b7280;
  --surface: #ffffff;
  --canvas: #f5f6fb;
  --border: #dfe3ed;
  --border-strong: #c9cfdd;
  --focus: #2563eb;
  --shadow: 0 18px 45px rgba(31, 41, 74, 0.1);
  --radius-lg: 24px;
  --radius-md: 14px;
  --radius-sm: 9px;
  --transition: 180ms ease;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  background: var(--canvas);
  color: var(--ink);
  line-height: 1.55;
}

button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button { touch-action: manipulation; }

button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 68%, transparent);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 8px;
  left: 8px;
  transform: translateY(-150%);
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: white;
}

.skip-link:focus { transform: translateY(0); }

.topbar {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 clamp(20px, 5vw, 72px);
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.92);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 1.08rem;
  font-weight: 750;
  text-decoration: none;
  letter-spacing: -0.02em;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--primary);
  color: white;
}

.brand-mark svg { width: 25px; height: 25px; fill: currentColor; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.status-chip {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted-ink);
  font-size: 0.84rem;
  font-weight: 650;
}

.status-chip:hover { border-color: var(--border-strong); background: #fafbff; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #9ca3af; box-shadow: 0 0 0 4px #f3f4f6; }
.status-chip.online .status-dot { background: #16a34a; box-shadow: 0 0 0 4px #dcfce7; }
.status-chip.offline .status-dot { background: #dc2626; box-shadow: 0 0 0 4px #fee2e2; }

.icon-button {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--muted-ink);
}

.icon-button:hover { background: var(--primary-soft); color: var(--primary); }
.icon-button svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }

main { width: min(1480px, 100%); margin: 0 auto; padding: 48px clamp(20px, 5vw, 72px) 64px; }

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 48px;
  margin-bottom: 32px;
}

.eyebrow, .kicker {
  margin: 0 0 8px;
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.intro h1 {
  max-width: 780px;
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.7rem);
  line-height: 1.04;
  letter-spacing: -0.055em;
  text-wrap: balance;
}

.intro-copy { max-width: 720px; margin: 18px 0 0; color: var(--muted-ink); font-size: 1.05rem; }

.privacy-note {
  max-width: 330px;
  display: flex;
  gap: 12px;
  padding: 16px;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-md);
  background: var(--accent-soft);
}

.privacy-note svg { width: 26px; height: 26px; flex: none; fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.privacy-note strong, .privacy-note span { display: block; }
.privacy-note strong { color: #14532d; font-size: 0.88rem; }
.privacy-note span { margin-top: 2px; color: #3f6350; font-size: 0.78rem; }

.workspace-grid { display: grid; grid-template-columns: minmax(360px, 0.84fr) minmax(480px, 1.16fr); gap: 24px; align-items: stretch; }
.panel { min-width: 0; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow); }
.input-panel { padding: clamp(22px, 3vw, 34px); }
.result-panel { min-height: 760px; padding: clamp(22px, 3vw, 34px); overflow: hidden; }

.panel-heading, .result-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.panel-heading > div { display: flex; gap: 13px; align-items: center; }
.panel-heading h2, .result-header h2, .result-empty h2, .loading-state h2, .result-error h2 { margin: 0; font-size: 1.35rem; line-height: 1.2; letter-spacing: -0.025em; }
.panel-heading .kicker { margin-bottom: 2px; }

.step { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: var(--primary-soft); color: var(--primary); font-size: 0.85rem; font-weight: 800; }
.text-button, .copy-button { min-height: 40px; border: 0; background: transparent; color: var(--primary); font-weight: 750; }
.text-button:hover, .copy-button:hover { color: var(--primary-hover); text-decoration: underline; text-underline-offset: 3px; }

form { margin-top: 28px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field-row-3 { grid-template-columns: 1.1fr 0.95fr 0.95fr; }
.field { margin-bottom: 19px; min-width: 0; }
.field label { display: block; margin-bottom: 7px; color: #273149; font-size: 0.84rem; font-weight: 720; }
.field label span { color: var(--danger); }
.label-line { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.label-line > span { color: var(--subtle-ink); font-size: 0.75rem; font-variant-numeric: tabular-nums; }

input, select, textarea {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: white;
  color: var(--ink);
  transition: border-color var(--transition), box-shadow var(--transition);
}

input, select { min-height: 47px; padding: 10px 12px; }
textarea { min-height: 230px; padding: 13px 14px; resize: vertical; line-height: 1.6; }
input:hover, select:hover, textarea:hover { border-color: #a8afbf; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); outline: 0; }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--danger); }
.field-help, .field-error { min-height: 18px; margin: 6px 0 0; font-size: 0.75rem; }
.field-help { color: var(--subtle-ink); }
.field-error { color: var(--danger); }

.error-summary { margin-bottom: 18px; padding: 14px 16px; border: 1px solid #fecaca; border-radius: 10px; background: var(--danger-soft); color: #7f1d1d; }
.error-summary ul { margin: 6px 0 0; padding-left: 20px; }
.error-summary a { color: inherit; }

.primary-button, .secondary-button {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border-radius: 11px;
  font-weight: 760;
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
}

.primary-button { width: 100%; border: 1px solid var(--primary); background: var(--primary); color: white; }
.primary-button:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.primary-button:active, .secondary-button:active { transform: scale(0.985); }
.primary-button:disabled { cursor: wait; opacity: 0.58; }
.primary-button svg, .secondary-button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.primary-button svg:first-child { fill: none; }
.primary-button.compact { width: auto; padding: 0 22px; }

.secondary-button { padding: 0 16px; border: 1px solid var(--border-strong); background: white; color: #313b51; }
.secondary-button:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.model-note { margin: 11px 0 0; text-align: center; color: var(--subtle-ink); font-size: 0.72rem; }

.result-empty, .loading-state, .result-error { min-height: 690px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.result-empty > p:not(.kicker), .loading-state > p:not(.kicker), .result-error p { max-width: 470px; margin: 12px auto 0; color: var(--muted-ink); }
.empty-illustration { width: 180px; margin-bottom: 20px; color: var(--primary); }
.empty-illustration svg { width: 100%; }
.empty-illustration .staff { fill: none; stroke: #dfe3ed; stroke-width: 2; }
.empty-illustration .note { fill: var(--primary-soft); stroke: var(--primary); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.empty-points { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 18px; margin-top: 30px; }
.empty-demo-button { margin-top: 22px; }
.empty-points span { display: inline-flex; align-items: center; gap: 6px; color: var(--muted-ink); font-size: 0.8rem; font-weight: 650; }
.empty-points svg { width: 17px; height: 17px; fill: none; stroke: var(--accent); stroke-width: 2.4; }

.loading-mark { height: 66px; display: flex; align-items: end; gap: 7px; margin-bottom: 22px; }
.loading-mark span { width: 8px; border-radius: 999px; background: var(--primary); animation: bars 1s ease-in-out infinite alternate; }
.loading-mark span:nth-child(1) { height: 28px; }
.loading-mark span:nth-child(2) { height: 54px; animation-delay: -0.35s; }
.loading-mark span:nth-child(3) { height: 40px; animation-delay: -0.7s; }
.skeleton { width: min(420px, 90%); display: grid; gap: 10px; margin-top: 32px; }
.skeleton span { height: 13px; border-radius: 999px; background: #edf0f6; animation: pulse 1.4s ease-in-out infinite alternate; }
.skeleton span:nth-child(2) { width: 82%; }
.skeleton span:nth-child(3) { width: 64%; }

.result-content { animation: reveal 300ms ease-out; }
.result-header { padding-bottom: 24px; border-bottom: 1px solid var(--border); }
.result-header > div { min-width: 0; }
.result-header > div > p:last-child { margin: 9px 0 0; color: var(--muted-ink); overflow-wrap: anywhere; }

.signal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 20px 0; }
.signal-card { padding: 16px; border-radius: 12px; }
.signal-card > span { display: block; margin-bottom: 7px; font-size: 0.75rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; }
.signal-card ul { margin: 0; padding-left: 19px; color: #344054; font-size: 0.84rem; }
.signal-card li + li { margin-top: 4px; }
.success-card { border: 1px solid #bbf7d0; background: var(--accent-soft); }
.success-card > span { color: #166534; }
.focus-card { border: 1px solid #fde68a; background: var(--warning-soft); }
.focus-card > span { color: #854d0e; }

.tab-list { display: flex; gap: 4px; padding: 4px; border-radius: 11px; background: #f0f2f7; overflow-x: auto; }
.tab-list button { flex: 1; min-width: max-content; min-height: 42px; padding: 8px 14px; border: 0; border-radius: 8px; background: transparent; color: var(--muted-ink); font-size: 0.82rem; font-weight: 720; }
.tab-list button[aria-selected="true"] { background: white; color: var(--primary); box-shadow: 0 1px 4px rgba(27, 37, 64, 0.1); }
.tab-panel { padding-top: 18px; }

.schedule { display: grid; gap: 10px; }
.day-card { display: grid; grid-template-columns: 105px 1fr; gap: 14px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px; }
.day-label { display: flex; flex-direction: column; gap: 2px; }
.day-label strong { font-size: 0.86rem; }
.day-label span { color: var(--subtle-ink); font-size: 0.72rem; font-variant-numeric: tabular-nums; }
.practice-blocks { display: grid; gap: 8px; }
.practice-block { position: relative; padding-left: 16px; }
.practice-block::before { content: ""; position: absolute; top: 7px; left: 0; width: 6px; height: 6px; border-radius: 50%; background: var(--primary); }
.practice-block strong { display: block; font-size: 0.82rem; }
.practice-block p { margin: 2px 0 0; color: var(--muted-ink); font-size: 0.76rem; }

.message-card { margin-bottom: 14px; padding: 17px; border: 1px solid var(--border); border-radius: 12px; background: #fafbfe; }
.message-card > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.message-card span { font-size: 0.8rem; font-weight: 800; }
.message-card p { margin: 10px 0 0; color: #344054; white-space: pre-wrap; }
.copy-button { min-height: 34px; }

.tab-panel h3 { margin: 0 0 10px; font-size: 0.92rem; }
.goal-list { margin: 0; padding-left: 24px; color: #344054; }
.goal-list li { padding: 7px 0; }
.unknown-card { margin-top: 18px; padding: 15px 17px; border: 1px solid #fde68a; border-radius: 12px; background: var(--warning-soft); }
.unknown-card strong { color: #854d0e; font-size: 0.82rem; }
.unknown-card ul { margin: 7px 0 0; padding-left: 20px; color: #5f4a26; font-size: 0.82rem; }

.result-error svg { width: 48px; height: 48px; margin-bottom: 16px; fill: none; stroke: var(--danger); stroke-width: 1.8; stroke-linecap: round; }
.result-error > div { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 22px; }

.trust-strip { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 24px; border: 1px solid var(--border); border-radius: 16px; background: white; overflow: hidden; }
.trust-strip div { padding: 19px 24px; text-align: center; }
.trust-strip div + div { border-left: 1px solid var(--border); }
.trust-strip strong, .trust-strip span { display: block; }
.trust-strip strong { color: var(--primary); font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.trust-strip span { margin-top: 2px; color: var(--muted-ink); font-size: 0.76rem; }

dialog { width: min(520px, calc(100% - 32px)); padding: 0; border: 0; border-radius: 20px; box-shadow: 0 24px 80px rgba(10, 19, 44, 0.3); }
dialog::backdrop { background: rgba(13, 20, 38, 0.58); backdrop-filter: blur(3px); }
dialog form { margin: 0; padding: 26px; }
.dialog-heading { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.dialog-heading h2 { margin: 0; letter-spacing: -0.03em; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 5px; }
.connection-result { min-height: 22px; margin: 12px 0 0; color: var(--muted-ink); font-size: 0.8rem; text-align: right; }

.toast { position: fixed; z-index: 100; right: 22px; bottom: 22px; max-width: min(360px, calc(100% - 44px)); padding: 12px 16px; border-radius: 10px; background: var(--ink); color: white; box-shadow: var(--shadow); font-size: 0.84rem; }

[hidden] { display: none !important; }
@keyframes bars { to { height: 18px; opacity: 0.55; } }
@keyframes pulse { to { opacity: 0.42; } }
@keyframes reveal { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 1020px) {
  .intro { grid-template-columns: 1fr; gap: 22px; }
  .privacy-note { max-width: 480px; }
  .workspace-grid { grid-template-columns: 1fr; }
  .result-panel { min-height: auto; }
  .result-empty, .loading-state, .result-error { min-height: 560px; }
}

@media (max-width: 620px) {
  .topbar { height: 64px; padding: 0 16px; }
  .status-chip { width: 42px; min-width: 42px; padding: 0; justify-content: center; }
  .status-chip #connectionLabel { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  main { padding: 32px 14px 40px; }
  .intro h1 { font-size: 2.05rem; }
  .panel { border-radius: 18px; }
  .input-panel, .result-panel { padding: 20px 16px; }
  .field-row, .field-row-3, .signal-grid { grid-template-columns: 1fr; gap: 0; }
  .panel-heading { align-items: center; }
  .result-header { flex-direction: column; }
  .result-header .secondary-button { width: 100%; }
  .day-card { grid-template-columns: 1fr; gap: 10px; }
  .day-label { flex-direction: row; align-items: baseline; justify-content: space-between; }
  .trust-strip { grid-template-columns: 1fr; }
  .trust-strip div + div { border-left: 0; border-top: 1px solid var(--border); }
  .dialog-actions { flex-direction: column-reverse; }
  .dialog-actions button { width: 100%; }
}

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