/* ==========================================================================
   Slack Remind Builder — Design Tokens
   Signature: every part of a /remind command keeps ONE consistent color
   across all three modes — command / target / message / frequency / time.
   Learning the colors = learning the grammar.
   ========================================================================== */

:root {
  /* spacing scale — keep every gap in the app tied to this rhythm */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;

  --text-2xs: 12px;
  --text-xs: 13px;
  --text-sm: 14px;
  --text-md: 15px;
  --text-lg: 16px;
  --text-xl: 18px;
  --text-2xl: 20px;

  /* palette (light) — true neutral grays, no blue tint, so text reads as
     plain black/gray like a typical site rather than "tinted" */
  --bg: #FAFAFA;
  --surface: #FFFFFF;
  --surface-alt: #F4F4F5;
  --border: #E4E4E7;
  --text: #18181B;
  --text-muted: #52525B;
  --text-faint: #6B6B75;

  --accent: #5B4FE9;
  --accent-hover: #4A3FD1;
  --accent-soft: #EDEBFC;
  --accent-contrast: #FFFFFF;

  --danger: #DC2626;
  --danger-soft: #FEF2F2;
  --success: #16A34A;
  --success-soft: #F0FDF4;

  /* token colors — the signature system */
  --tok-command: #5B4FE9;   /* /remind */
  --tok-command-soft: #EDEBFC;
  --tok-target: #C2410C;    /* who */
  --tok-target-soft: #FFF1E8;
  --tok-message: #15803D;   /* what */
  --tok-message-soft: #F0FDF4;
  --tok-frequency: #92650A; /* every/in/next */
  --tok-frequency-soft: #FEF9E7;
  --tok-time: #2563EB;      /* at HH:MM */
  --tok-time-soft: #EFF4FE;

  --radius-s: 8px;
  --radius-m: 14px;
  --radius-l: 20px;

  --shadow-card: 0 1px 2px rgba(24,24,27,0.04), 0 8px 24px rgba(24,24,27,0.06);
  --shadow-pop: 0 12px 32px rgba(24,24,27,0.14);

  --font-display: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "Segoe UI", sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic", "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;

  color-scheme: light;
}

html.dark {
  --bg: #18181B;
  --surface: #202023;
  --surface-alt: #27272A;
  --border: #3F3F46;
  --text: #FAFAFA;
  --text-muted: #A1A1AA;
  --text-faint: #9C9CA8;

  --accent: #8C7FFF;
  --accent-hover: #A296FF;
  --accent-soft: #2A2650;
  --accent-contrast: #12101F;

  --danger: #F87171;
  --danger-soft: #3A1D1E;
  --success: #4ADE80;
  --success-soft: #16301F;

  --tok-command: #9B8FFF;
  --tok-command-soft: #2A2650;
  --tok-target: #FB923C;
  --tok-target-soft: #3A2419;
  --tok-message: #4ADE80;
  --tok-message-soft: #16301F;
  --tok-frequency: #FACC15;
  --tok-frequency-soft: #382D12;
  --tok-time: #60A5FA;
  --tok-time-soft: #182A44;

  --shadow-card: 0 1px 2px rgba(0,0,0,0.3), 0 8px 24px rgba(0,0,0,0.35);
  --shadow-pop: 0 12px 32px rgba(0,0,0,0.5);

  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background 0.2s ease, color 0.2s ease;
}

/* guarantee every form control and button uses the same font as the rest
   of the page — browsers default these to the OS UI font otherwise,
   which is the #1 cause of a page feeling visually inconsistent */
button, input, select, textarea {
  font-family: inherit;
  color: inherit;
}

/* generic utility */
.is-hidden { display: none !important; }

/* ============ HEADER ============ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: var(--space-3) var(--space-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { font-size: var(--text-2xl); }
.brand-name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--text-lg);
  letter-spacing: -0.01em;
}
.theme-toggle {
  border: 1px solid var(--border);
  background: var(--surface-alt);
  border-radius: 999px;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: var(--text-lg);
  transition: transform 0.15s ease, background 0.15s ease;
}
.theme-toggle:hover { background: var(--accent-soft); transform: translateY(-1px); }

.header-actions { display: flex; align-items: center; gap: var(--space-2); }
.lang-toggle {
  border: 1px solid var(--border);
  background: var(--surface-alt);
  border-radius: 999px;
  height: 38px;
  padding: 0 var(--space-3);
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  font-weight: 700;
  transition: transform 0.15s ease, background 0.15s ease;
}
.lang-toggle:hover { background: var(--accent-soft); transform: translateY(-1px); }
.lang-toggle-option { color: var(--text-faint); padding: 2px 3px; border-radius: 4px; }
.lang-toggle-option.is-active { color: var(--accent); background: var(--accent-soft); }
.lang-toggle-sep { color: var(--text-faint); }

/* ============ HERO ============ */
.hero {
  max-width: 780px;
  margin: 0 auto;
  padding: var(--space-4) var(--space-6) var(--space-2);
  text-align: center;
}
.hero-mono {
  font-family: var(--font-mono);
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 10px;
  border-radius: 8px;
}
.hero-sub {
  color: var(--text-muted);
  font-size: var(--text-md);
  margin: 0;
}

/* ============ MODE TABS ============ */
.mode-tabs {
  max-width: 780px;
  margin: 0 auto;
  padding: 0 var(--space-6) var(--space-2);
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}
.tab-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: var(--space-2) var(--space-4); /* pill nav */
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: var(--text-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}
.tab-btn:hover { border-color: var(--accent); color: var(--text); }
.tab-btn.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
  box-shadow: 0 6px 16px rgba(91,79,233,0.25);
}
.tab-icon { font-size: var(--text-md); }

/* ============ MAIN / PANELS ============ */
.app-main {
  max-width: 1080px;
  margin: 0 auto;
  padding: var(--space-4) var(--space-6) var(--space-8);
}
.mode-panel { display: none; }
.mode-panel.is-active { display: block; animation: fadeIn 0.25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ============ CARD ============ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-card);
  padding: var(--space-5) var(--space-6);
  margin-bottom: var(--space-4);
}
.card-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--text-xl);
  letter-spacing: -0.01em;
  margin: 0 0 6px;
}
.card-subtitle {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-md);
  margin: 0 0 12px;
}
.card-desc { color: var(--text-muted); font-size: var(--text-sm); margin: 0 0 var(--space-4); }

/* ============ FORM ============ */
.panel-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: var(--space-6);
  align-items: start;
}
@media (max-width: 860px) {
  .panel-grid { grid-template-columns: 1fr; }
}

.field-group { margin-bottom: var(--space-4); }
.field-label {
  display: block;
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}
.field-hint { font-size: var(--text-2xs); color: var(--text-faint); margin: var(--space-2) 0 0; }
.field-hint.is-warning { color: var(--tok-frequency); font-weight: 600; }
.field-error {
  font-size: var(--text-2xs);
  color: var(--danger);
  margin: var(--space-2) 0 0;
  min-height: 1em;
}

.segmented {
  display: inline-flex;
  background: var(--surface-alt);
  border-radius: var(--radius-m);
  padding: 4px;
  gap: 4px;
}
.segmented-wrap { flex-wrap: wrap; }
.seg-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: var(--text-xs);
  padding: var(--space-2) var(--space-4); /* pill toggle */
  border-radius: var(--radius-s);
  cursor: pointer;
  transition: all 0.15s ease;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.is-active {
  background: var(--surface);
  color: var(--accent);
  font-weight: 800;
  box-shadow: var(--shadow-card), inset 0 0 0 1.5px var(--accent);
}
.seg-btn.is-active::before {
  content: '✓';
  display: inline-block;
  margin-right: 4px;
  font-weight: 800;
}

.text-input, .text-area, .select-input {
  width: 100%;
  font-family: var(--font-body);
  font-size: var(--text-md);
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-s);
  padding: var(--space-3) var(--space-3); /* input */
  margin-top: var(--space-2);
  transition: border-color 0.15s ease;
}
.text-input:focus, .text-area:focus, .select-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.text-area { resize: vertical; font-family: var(--font-body); }
.target-input.is-hidden { display: none; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }

/* ============ CUSTOM TIME PICKER (avoids native <input type=time> seconds-display quirks on some OS/browsers) ============ */
.time-select {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-2);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-s);
  padding: var(--space-1) var(--space-2);
  width: fit-content;
  transition: border-color 0.15s ease;
}
.time-select:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.time-select-input {
  border: none;
  background: transparent;
  font-family: var(--font-mono);
  font-size: var(--text-md);
  font-weight: 700;
  color: var(--text);
  padding: var(--space-2);
  cursor: pointer;
}
.time-select-input:focus { outline: none; }
.time-select-input:disabled { color: var(--text-faint); cursor: not-allowed; }
.time-select-sep { font-weight: 800; color: var(--text-faint); }

/* ============ CUSTOM DATE PICKER (avoids native <input type=date> weekday-rendering quirks) ============ */
.date-picker { position: relative; margin-top: var(--space-2); }
.date-picker-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0;
  cursor: pointer;
  text-align: left;
  color: var(--text);
}
.date-picker-trigger:hover { border-color: var(--accent); }
.date-picker-trigger:disabled { opacity: 0.45; cursor: not-allowed; }
.date-picker-trigger:disabled:hover { border-color: var(--border); }
.date-picker-trigger-text.is-placeholder { color: var(--text-faint); }
.date-picker-icon { font-size: var(--text-md); opacity: 0.7; }
.date-picker-popover {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 30;
  width: 280px;
  max-width: 90vw;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow-pop);
  padding: 14px;
}
.date-picker-popover.is-hidden { display: none; }
.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.cal-label { font-weight: 700; font-size: var(--text-sm); }
.cal-nav {
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  border-radius: 8px;
  width: 30px;
  height: 30px;
  cursor: pointer;
  font-size: var(--text-md);
  line-height: 1;
}
.cal-nav:hover { border-color: var(--accent); color: var(--accent); }
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}
.cal-weekday {
  text-align: center;
  font-size: var(--text-2xs);
  font-weight: 700;
  color: var(--text-faint);
  padding: 4px 0;
}
.cal-day {
  border: none;
  background: transparent;
  border-radius: 8px;
  padding: 7px 0;
  font-size: var(--text-xs);
  color: var(--text);
  cursor: pointer;
}
.cal-day:hover { background: var(--accent-soft); }
.cal-day.is-today { font-weight: 800; color: var(--accent); }
.cal-day.is-selected { background: var(--accent); color: var(--accent-contrast); font-weight: 700; }
.cal-day.is-empty { cursor: default; visibility: hidden; }
.cal-day.is-past { opacity: 0.3; cursor: not-allowed; text-decoration: line-through; }
.cal-day.is-past:hover { background: transparent; }

.schedule-block { padding-top: 4px; }

/* ============ MENTION QUICK-INSERT (@here/@channel/@everyone) ============ */
.mention-insert-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-top: var(--space-3);
}
.mention-insert-row.is-hidden { display: none; }
.mention-insert-label { font-size: var(--text-2xs); color: var(--text-faint); font-weight: 600; }
.mention-chip {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--tok-target);
  background: var(--tok-target-soft);
  border: 1px solid transparent;
  border-radius: var(--radius-s);
  padding: 4px var(--space-2);
  cursor: pointer;
  transition: all 0.15s ease;
}
.mention-chip:hover { border-color: var(--tok-target); transform: translateY(-1px); }

.weekday-picker { margin: var(--space-4) 0; }
.day-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.day-chip {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-weight: 700;
  font-size: var(--text-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}
.day-chip:hover { border-color: var(--accent); }
.day-chip.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}
.day-chip.is-active::after {
  content: '✓';
  position: absolute;
  top: -3px;
  right: -3px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--success);
  color: #fff;
  border: 1.5px solid var(--surface);
  font-size: 9px;
  font-weight: 800;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.form-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.btn {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: var(--text-sm);
  border-radius: var(--radius-s);
  padding: var(--space-3) var(--space-5); /* button */
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: all 0.15s ease;
}
.btn-primary { background: var(--accent); color: var(--accent-contrast); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text-muted); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-link {
  background: transparent;
  border: none;
  color: var(--accent);
  font-weight: 700;
  padding: 10px 0;
  text-align: left;
}
.btn-link:hover { text-decoration: underline; }

/* ============ PREVIEW / COMMAND CARD ============ */
.preview-col { display: flex; flex-direction: column; gap: 22px; }

.command-card {
  background: var(--surface);
  border: 2px solid var(--accent);
  border-radius: var(--radius-l);
  box-shadow: 0 4px 8px rgba(91,79,233,0.08), 0 20px 44px rgba(91,79,233,0.16);
  padding: 24px;
  position: relative;
  overflow: hidden;
}
.command-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 5px;
  background: linear-gradient(90deg, var(--tok-command), var(--tok-target), var(--tok-message), var(--tok-frequency), var(--tok-time));
}
.command-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin: 6px 0 14px;
}
.command-card-head-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.command-card-label {
  font-size: var(--text-2xs);
  font-weight: 800;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.btn-copy {
  background: var(--accent);
  color: var(--accent-contrast);
  border: none;
  border-radius: var(--radius-s);
  padding: var(--space-3) var(--space-5); /* button */
  font-weight: 800;
  font-size: var(--text-xs);
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 6px 16px rgba(91,79,233,0.3);
}
.btn-copy:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-open-slack {
  font-size: var(--text-xs);
  padding: var(--space-3) var(--space-4);
}
.paste-hint {
  font-size: var(--text-2xs);
  color: var(--text-faint);
  margin: var(--space-2) 0 0;
  text-align: right;
}
.btn-reset-command {
  display: block;
  width: max-content;
  margin: var(--space-3) 0 0 auto;
}
.command-card-body {
  background: var(--accent-soft);
  border: 1.5px dashed var(--accent);
  border-radius: var(--radius-m);
  padding: 20px;
}
.command-text {
  font-family: var(--font-mono);
  font-size: var(--text-xl);
  font-weight: 700;
  line-height: 2;
  color: var(--text);
  word-break: break-word;
  white-space: pre-wrap;
}
.explain-block { margin-top: 16px; }
.explain-block.is-hidden { display: none; }

/* ============ NEXT-RUN PREVIEW ============ */
.next-run-list { display: flex; flex-direction: column; }
.next-run-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  border-top: 1px dashed var(--border);
}
.next-run-row:first-child { border-top: none; }
.next-run-row-label {
  font-size: var(--text-2xs);
  font-weight: 700;
  color: var(--text-faint);
  white-space: nowrap;
}
.next-run-row:first-child .next-run-row-label {
  color: var(--accent);
}
.next-run-row-date {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--text);
  text-align: right;
}
.next-run-row:first-child .next-run-row-date {
  font-weight: 800;
  font-size: var(--text-md);
}
#nextRunNote { line-height: 1.6; }

.explain-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px dashed var(--border);
}
.explain-step:first-child { border-top: none; }
.explain-chip {
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 6px;
  white-space: nowrap;
}
.explain-text { font-size: var(--text-xs); color: var(--text-muted); padding-top: 2px; }

/* token colors applied via data-token attr */
[data-token="command"] { color: var(--tok-command); background: var(--tok-command-soft); }
[data-token="target"] { color: var(--tok-target); background: var(--tok-target-soft); }
[data-token="message"] { color: var(--tok-message); background: var(--tok-message-soft); }
[data-token="frequency"] { color: var(--tok-frequency); background: var(--tok-frequency-soft); }
[data-token="time"] { color: var(--tok-time); background: var(--tok-time-soft); }

/* ============ SAMPLE (自然文モードのみ) ============ */
.sample-inline { margin-top: var(--space-5); padding: var(--space-5); border: 1px solid var(--border); border-radius: var(--radius-l); }
.sample-list { display: flex; flex-direction: column; gap: 8px; }
.sample-item {
  text-align: left;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  padding: var(--space-2) var(--space-3); /* list row */
  font-size: var(--text-xs);
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s ease;
}
.sample-item:hover { border-color: var(--accent); background: var(--accent-soft); }
.sample-item .sample-label { font-weight: 700; color: var(--accent); margin-right: 6px; font-size: var(--text-2xs); }
.empty-note { color: var(--text-faint); font-size: var(--text-xs); margin: 0; }

/* ============ QUICK TEMPLATES (かんたん作成モード右側) ============ */
.template-list { display: flex; flex-direction: column; gap: 8px; }
.template-item {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  width: 100%;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s ease;
}
.template-item:hover { border-color: var(--accent); background: var(--accent-soft); transform: translateX(2px); }
.template-item-icon { font-size: var(--text-lg); line-height: 1; flex-shrink: 0; }
.template-item-label { flex: 1; }
.template-item-meta { font-size: var(--text-2xs); color: var(--text-faint); font-weight: 500; white-space: nowrap; }

/* ============ LEARN MODE: decompose ============ */
.decompose-source {
  background: var(--surface-alt);
  border-radius: var(--radius-m);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
  font-family: var(--font-mono);
  font-size: var(--text-md);
  overflow-x: auto;
  white-space: nowrap;
}
.decompose-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}
.decompose-chip {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 700;
  padding: var(--space-2) var(--space-3); /* chip */
  border-radius: var(--radius-s);
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.decompose-chip:hover { transform: translateY(-2px); box-shadow: var(--shadow-card); }
.decompose-chip.is-selected { border-color: currentColor; }

.decompose-detail {
  background: var(--surface-alt);
  border-radius: var(--radius-m);
  padding: var(--space-4);
  margin-bottom: var(--space-5);
  font-size: var(--text-sm);
  min-height: 24px;
}
.decompose-detail strong { display: block; margin-bottom: 4px; }

/* ============ GRAMMAR CARDS ============ */
.grammar-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: var(--space-4);
}
.grammar-card {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  padding: 16px;
}
.grammar-syntax {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: var(--text-md);
  color: var(--accent);
  margin-bottom: 6px;
}
.grammar-meaning { font-size: var(--text-xs); color: var(--text); margin-bottom: 10px; }
.grammar-example {
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  color: var(--text-muted);
  background: var(--surface);
  border-radius: 6px;
  padding: var(--space-2) var(--space-3); /* code chip */
  word-break: break-word;
}

/* ============ GRAMMAR BUILDER ============ */
.builder-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}
.builder-connector { font-weight: 700; color: var(--text-muted); font-family: var(--font-mono); }
.builder-time-wrap { display: inline-flex; align-items: center; gap: 10px; }
.select-input { width: auto; margin-top: 0; padding: var(--space-3) var(--space-3); } /* input */
.select-input.select-block { width: 100%; margin-top: var(--space-2); margin-bottom: var(--space-4); }
.select-input:disabled,
.text-input:disabled,
.day-chip:disabled,
.seg-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.builder-result {
  background: var(--surface-alt);
  border-radius: var(--radius-m);
  padding: 16px 18px;
}
.phrase-output {
  display: block;
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  color: var(--accent);
  font-weight: 700;
  margin: 4px 0 14px;
}
.meaning-output { font-size: var(--text-md); margin: 4px 0 0; }

/* ============ DICTIONARY ============ */
.dict-table { display: flex; flex-direction: column; border-top: 1px solid var(--border); }
.dict-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border);
  background: transparent;
  border-left: none; border-right: none; border-top: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font-family: var(--font-body);
  transition: background 0.15s ease;
}
.dict-row:hover { background: var(--surface-alt); }
.dict-syntax { font-family: var(--font-mono); font-weight: 700; font-size: var(--text-sm); }
.dict-meaning { color: var(--text-muted); font-size: var(--text-xs); }
.dict-detail {
  margin-top: 14px;
  padding: 14px 16px;
  background: var(--accent-soft);
  border-radius: var(--radius-m);
  font-size: var(--text-xs);
  display: none;
}
.dict-detail.is-visible { display: block; }
.dict-note { margin-top: 14px; }

/* ============ NATURAL MODE ============ */
.natural-textarea { font-size: var(--text-md); }
.clarify-options { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.clarify-btn {
  border: 1.5px solid var(--border);
  background: var(--surface-alt);
  border-radius: var(--radius-s);
  padding: var(--space-3) var(--space-5); /* button */
  font-weight: 700;
  font-size: var(--text-xs);
  cursor: pointer;
  color: var(--text);
  transition: all 0.15s ease;
}
.clarify-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

.parse-result {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  overflow: hidden;
  margin-bottom: var(--space-5);
}
.parse-cell { background: var(--surface); padding: 14px 16px; }
.parse-cell-label { font-size: var(--text-2xs); color: var(--text-faint); font-weight: 700; margin-bottom: 4px; }
.parse-cell-value { font-size: var(--text-md); font-weight: 700; }

/* ============ TOAST ============ */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: var(--bg);
  padding: var(--space-3) var(--space-6); /* toast */
  border-radius: 999px;
  font-weight: 700;
  font-size: var(--text-sm);
  box-shadow: var(--shadow-pop);
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  z-index: 100;
}
.toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============ RESPONSIVE ============ */
@media (max-width: 600px) {
  .hero { padding: 40px 20px 20px; }
  .app-main { padding: 20px 16px 60px; }
  .card { padding: 20px; }
  .two-col { grid-template-columns: 1fr; }
  .tab-label { display: none; }
  .tab-btn { padding: 12px 14px; }
}

/* ============ REDUCED MOTION ============ */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* focus visibility */
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
