@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@500;700;800&family=IBM+Plex+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  --paper: #0D0F17;
  --paper-raised: #161927;
  --ink: #EEF0FA;
  --ink-soft: #9CA3BF;
  --ink-faint: #656C88;
  --line: #262B40;
  --line-soft: #1A1D2B;
  --accent: #5C7DFF;
  --accent-ink: #0A0D1A;
  --accent-soft: #1B2044;
  --mint: #3FBFA8;
  --mint-soft: #0E2622;
  --mint-line: #1D4A3F;
  --warn: #F0B133;
  --warn-soft: #2B2210;
  --warn-line: #4D3D14;
  --shadow-card: 0 1px 1px rgba(0,0,0,.3), 0 16px 40px -10px rgba(0,0,0,.6);
  --radius-lg: 18px;
  --radius-md: 10px;
  --radius-sm: 6px;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --paper: #F7F8FC;
    --paper-raised: #FFFFFF;
    --ink: #12141C;
    --ink-soft: #5B6178;
    --ink-faint: #9AA0B8;
    --line: #E3E5F0;
    --line-soft: #EEF0F8;
    --accent: #3A66F7;
    --accent-ink: #FFFFFF;
    --accent-soft: #E8ECFE;
    --mint: #0D9488;
    --mint-soft: #E6FBF6;
    --mint-line: #B3EEE1;
    --warn: #B45309;
    --warn-soft: #FEF3C7;
    --warn-line: #FDE68A;
    --shadow-card: 0 1px 1px rgba(18,20,28,.04), 0 12px 32px -10px rgba(18,20,28,.12);
    color-scheme: light;
  }
}

:root[data-theme="light"] {
  --paper: #F7F8FC;
  --paper-raised: #FFFFFF;
  --ink: #12141C;
  --ink-soft: #5B6178;
  --ink-faint: #9AA0B8;
  --line: #E3E5F0;
  --line-soft: #EEF0F8;
  --accent: #3A66F7;
  --accent-ink: #FFFFFF;
  --accent-soft: #E8ECFE;
  --mint: #0D9488;
  --mint-soft: #E6FBF6;
  --mint-line: #B3EEE1;
  --warn: #B45309;
  --warn-soft: #FEF3C7;
  --warn-line: #FDE68A;
  --shadow-card: 0 1px 1px rgba(18,20,28,.04), 0 12px 32px -10px rgba(18,20,28,.12);
  color-scheme: light;
}

:root[data-theme="dark"] {
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: "IBM Plex Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
  min-height: 100vh;
}

.app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 20px 64px;
}

@media (min-width: 640px) {
  .app {
    padding: 28px 32px 80px;
  }
}

/* ---------- Header ---------- */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 28px;
  margin-bottom: 8px;
}

.header__brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.header__logo {
  display: block;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  align-self: center;
}

.header__title {
  font-family: "Manrope", sans-serif;
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.01em;
}

.header__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge {
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  background: var(--line-soft);
  border: 1px solid var(--line);
}

/* theme switch: 3-way segmented control */
.theme-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  background: var(--line-soft);
}

.theme-switch button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-faint);
  cursor: pointer;
  transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}

.theme-switch button:hover {
  color: var(--ink-soft);
}

.theme-switch button[aria-pressed="true"] {
  background: var(--paper-raised);
  color: var(--accent);
  box-shadow: 0 1px 2px rgba(0,0,0,.06), 0 0 0 1px var(--line);
}

.theme-switch svg {
  width: 15px;
  height: 15px;
}

.btn--ghost {
  font-family: "IBM Plex Sans", sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 14px;
  cursor: pointer;
  transition: border-color .15s ease, color .15s ease;
}
.btn--ghost:hover { border-color: var(--ink-faint); color: var(--ink); }

/* ---------- Hero ---------- */
.hero {
  padding: 8px 0 40px;
  max-width: 640px;
}

.hero__trust {
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  color: var(--mint);
  background: var(--mint-soft);
  border: 1px solid var(--mint-line);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 18px;
}

.hero__trust::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--mint);
  flex-shrink: 0;
}

.hero__title {
  font-family: "Manrope", sans-serif;
  font-weight: 800;
  font-size: clamp(28px, 4.2vw, 40px);
  line-height: 1.12;
  letter-spacing: -0.025em;
  margin: 0 0 16px;
  text-wrap: balance;
}

.hero__title em {
  font-style: normal;
  color: var(--accent);
}

.hero__subtitle {
  font-size: 16px;
  color: var(--ink-soft);
  line-height: 1.6;
  margin: 0;
}

/* ---------- Workspace ---------- */
.tool-layout {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr;
}

@media (min-width: 900px) {
  .tool-layout {
    grid-template-columns: 1fr 1fr;
  }
  .input-panel {
    border-right: 1px solid var(--line);
  }
}

.panel {
  padding: 22px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  border: none;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
}

@media (min-width: 640px) {
  .panel {
    padding: 22px 24px 24px;
  }
}

.input-panel {
  border-bottom: 1px solid var(--line);
}

@media (min-width: 900px) {
  .input-panel { border-bottom: none; }
}

.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel__label {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel__label::before {
  content: none;
}

.onboarding {
  margin: 0;
  font-size: 12.5px;
  color: var(--ink-soft);
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}

/* Textarea */
.textarea {
  width: 100%;
  min-height: 220px;
  line-height: 1.75;
  font-size: 15.5px;
  font-family: "IBM Plex Sans", sans-serif;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  resize: vertical;
  background: var(--line-soft);
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

@media (min-width: 900px) {
  .textarea {
    min-height: 300px;
  }
}

.textarea::placeholder {
  color: var(--ink-faint);
}

.textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
  background: var(--paper-raised);
}

.option input:focus-visible,
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.textarea--result {
  background: var(--paper-raised);
}

.result-wrap {
  position: relative;
}

/* Result empty state */
.result-empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 8px;
  min-height: 220px;
  padding: 32px 20px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
}

.result-empty-state__icon {
  font-family: "IBM Plex Mono", monospace;
  font-size: 18px;
  color: var(--ink-faint);
  background: var(--line-soft);
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  margin-bottom: 2px;
}

.result-empty-state__title {
  margin: 0;
  font-weight: 600;
  font-size: 14px;
  color: var(--ink-soft);
}

.result-empty-state__desc {
  margin: 0;
  font-size: 12.5px;
  color: var(--ink-faint);
  max-width: 30ch;
}

.panel.is-empty {
  justify-content: center;
}

/* Stats bar */
.stats-bar {
  display: flex;
  gap: 18px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12.5px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  flex-wrap: wrap;
}

.stats-bar__dot {
  display: none;
}

/* Options */
.options-panel {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.option {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 10px 10px;
  margin: 0 -10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color .15s ease;
}

.option:hover {
  background: var(--line-soft);
}

.option input {
  margin-top: 3px;
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  background: var(--paper-raised);
  border: 1.5px solid var(--ink-faint);
  border-radius: 4px;
  flex-shrink: 0;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  position: relative;
  transition: border-color .15s ease, background-color .15s ease;
}

.option input:hover {
  border-color: var(--accent);
}

.option input:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.option input:checked::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 1px;
  width: 5px;
  height: 8px;
  border: solid var(--accent-ink);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.option__text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.option__title {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
}

.option__desc {
  font-size: 12.5px;
  color: var(--ink-faint);
}

.option--inline {
  font-size: 13px;
}

.option--select {
  cursor: default;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.select {
  font-family: "IBM Plex Sans", sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color .15s ease;
}

.select:hover {
  border-color: var(--accent);
}

.select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Buttons */
.action-bar {
  display: flex;
  gap: 10px;
  margin-top: 2px;
}

.btn {
  font-family: "IBM Plex Sans", sans-serif;
  font-size: 14.5px;
  font-weight: 600;
  border-radius: var(--radius-md);
  padding: 12px 18px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform .08s ease, box-shadow .15s ease, background-color .15s ease, border-color .15s ease, opacity .15s ease;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn--primary {
  flex: 1;
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 6px 18px -4px color-mix(in srgb, var(--accent) 55%, transparent);
}

.btn--primary:hover:not(:disabled) {
  box-shadow: 0 8px 22px -4px color-mix(in srgb, var(--accent) 65%, transparent);
}

.btn--primary:active:not(:disabled) {
  transform: translateY(1px);
}

.btn--secondary {
  background: transparent;
  border-color: var(--line);
  color: var(--ink-soft);
  flex: 0 0 auto;
}

.btn--secondary:hover {
  border-color: var(--ink-faint);
  color: var(--ink);
}

/* Summary */
.summary {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  font-weight: 500;
  color: var(--mint);
  background: var(--mint-soft);
  border: 1px solid var(--mint-line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

/* Length warnings (platform character limits) */
.length-warning-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.length-warning {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--warn);
  background: var(--warn-soft);
  border: 1px solid var(--warn-line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.length-warning--info {
  color: var(--ink-soft);
  background: var(--line-soft);
  border-color: var(--line);
}

.length-warning__icon {
  flex-shrink: 0;
  line-height: 1.4;
}

/* Footnote / trust strip */
.footnote {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  justify-content: center;
  padding-top: 36px;
  font-size: 12.5px;
  color: var(--ink-faint);
  text-align: center;
}

/* History panel */
.history-panel {
  max-width: 720px;
  margin: 24px auto 0;
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 20px 24px;
}

.history-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--line-soft);
}

.history-item__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: none;
  border: none;
  padding: 0;
  text-align: left;
  font-family: inherit;
  color: inherit;
  cursor: pointer;
}

.history-item__preview {
  font-size: 13.5px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item__meta {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  color: var(--ink-faint);
}

.history-item__delete {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-faint);
  cursor: pointer;
  transition: border-color .15s ease, color .15s ease;
}

.history-item__delete:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.history-empty {
  font-size: 13px;
  color: var(--ink-faint);
  text-align: center;
  padding: 16px 0;
}

/* FAQ */
.faq {
  max-width: 720px;
  margin: 24px auto 0;
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 24px;
}

.faq h2 {
  font-family: "Manrope", sans-serif;
  font-size: 17px;
  font-weight: 700;
  margin: 0 0 12px;
  color: var(--ink);
}

.faq details {
  border-top: 1px solid var(--line);
  padding: 10px 0;
  font-size: 14px;
}

.faq details:first-of-type {
  border-top: none;
}

.faq summary {
  cursor: pointer;
  font-weight: 500;
  color: var(--ink);
}

.faq p {
  color: var(--ink-soft);
  margin: 8px 0 0;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: var(--shadow-card);
  z-index: 100;
  max-width: 90vw;
  text-align: center;
}

/* iOS install hint */
.ios-hint {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  z-index: 100;
  color: var(--ink);
}

.ios-hint p {
  margin: 0;
}

[hidden] {
  display: none !important;
}
