/* 110 Sentences — minimal dark PWA */

:root {
  --bg: #0a0a0a;
  --bg-soft: #141414;
  --fg: #fafafa;
  --fg-dim: #8a8a8a;
  --fg-faint: #4a4a4a;
  --accent: #d4d4d4;
  --mask: #2a2a2a;
  --radius: 14px;
}

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

html,
body {
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family:
    -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui,
    sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
    env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px 12px;
  font-size: 13px;
  color: var(--fg-dim);
  letter-spacing: 0.04em;
}

.progress {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.meta-tags {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-faint);
}

.card-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding: 8px 24px 24px;
  overflow-y: auto;
}

.card {
  position: relative;
  background: var(--bg-soft);
  border-radius: var(--radius);
  padding: 28px 28px 24px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.sentence {
  font-size: clamp(1.15rem, 4.5vw, 1.65rem);
  line-height: 1.55;
  font-weight: 400;
  color: var(--fg);
  letter-spacing: -0.005em;
  white-space: pre-wrap;
}

.sentence .mask {
  display: inline-block;
  min-width: 2.5em;
  height: 1em;
  background: var(--mask);
  border-radius: 4px;
  vertical-align: -0.15em;
  margin: 0 0.05em;
}

.sentence-ko {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  font-size: clamp(0.92rem, 3.6vw, 1.05rem);
  line-height: 1.6;
  color: var(--fg-dim);
  letter-spacing: -0.005em;
  font-family:
    -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR",
    system-ui, sans-serif;
  white-space: pre-wrap;
}

.sentence-ko:empty {
  display: none;
}

.tts {
  position: absolute;
  top: 14px;
  right: 14px;
  background: transparent;
  border: 1px solid var(--fg-faint);
  color: var(--fg);
  width: 38px;
  height: 38px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 16px;
  display: grid;
  place-items: center;
  transition:
    border-color 180ms ease,
    background 180ms ease;
}

.tts:hover,
.tts:focus-visible {
  border-color: var(--fg-dim);
  background: rgba(255, 255, 255, 0.04);
}

.tts:active {
  background: rgba(255, 255, 255, 0.08);
}

.meta-panel {
  margin-top: 16px;
  padding: 14px 4px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 12.5px;
  color: var(--fg-dim);
  line-height: 1.5;
}

.meta-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-soft);
  color: var(--fg);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition:
    background 160ms ease,
    border-color 160ms ease;
}

.meta-toggle:hover,
.meta-toggle:focus-visible {
  background: #1c1c1c;
  border-color: rgba(255, 255, 255, 0.12);
  outline: none;
}

.meta-toggle[aria-expanded="true"] {
  background: #1a1a1a;
  border-color: rgba(255, 255, 255, 0.12);
}

.meta-toggle-arrow {
  color: var(--fg-dim);
  font-size: 12px;
}

.meta-content[hidden] {
  display: none;
}

.meta-content {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.meta-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.meta-section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--fg-faint);
  font-weight: 500;
  padding: 4px 0 2px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  margin-bottom: 6px;
}

.md-item {
  padding: 14px 14px;
  background: rgba(255, 255, 255, 0.025);
  border-radius: 8px;
  border-left: 2px solid rgba(255, 255, 255, 0.12);
}

.md-item + .md-item {
  margin-top: 0;
}

.md-section {
  margin-top: 10px;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--fg-dim);
}

.md-label {
  display: inline-block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-faint);
  font-weight: 500;
  margin-right: 6px;
}

.md-mono {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 11.5px;
  color: var(--accent);
}

.md-list {
  margin: 4px 0 0;
  padding-left: 18px;
  color: var(--fg-dim);
}

.md-list li {
  margin-bottom: 3px;
  font-size: 12.5px;
}

.md-examples {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.md-ex {
  background: rgba(255, 255, 255, 0.03);
  border-radius: 6px;
  padding: 8px 10px;
}

.md-ex-en {
  color: var(--fg);
  font-size: 12.5px;
  line-height: 1.5;
}

.md-ex-ko {
  color: var(--fg-dim);
  font-size: 11.5px;
  margin-top: 2px;
  font-family:
    -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR",
    system-ui, sans-serif;
}

.md-mistake {
  margin-top: 12px;
  padding: 10px 12px;
  background: rgba(255, 200, 100, 0.05);
  border-left: 2px solid rgba(255, 200, 100, 0.4);
  border-radius: 6px;
}

.md-mistake .md-label {
  color: rgba(255, 200, 100, 0.85);
  display: block;
  margin-bottom: 4px;
}

.md-mistake-body {
  color: var(--fg-dim);
  font-size: 12px;
}

.meta-row.note-row {
  display: block;
  color: var(--fg-faint);
  font-size: 11.5px;
  font-style: italic;
  padding-top: 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  margin-top: 4px;
}

.meta-row:empty {
  display: none;
}

.tag {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--accent);
  font-size: 11px;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  border: 1px solid transparent;
  cursor: pointer;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease;
}

.tag:hover,
.tag:focus-visible {
  background: rgba(255, 255, 255, 0.09);
  color: var(--fg);
  outline: none;
}

.tag.active {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--fg-dim);
  color: var(--fg);
}

.meta-detail {
  display: none;
  margin-top: 4px;
  padding: 14px 14px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 10px;
  border-left: 2px solid var(--fg-dim);
  font-size: 13px;
  line-height: 1.55;
  color: var(--fg);
}

.meta-detail.open {
  display: block;
}

.md-head {
  font-size: 13.5px;
  color: var(--fg);
  margin-bottom: 6px;
  font-weight: 500;
  line-height: 1.45;
}

.md-key {
  display: inline-block;
  padding: 1px 7px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  font-size: 11px;
  margin-right: 6px;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.md-ko {
  color: var(--fg-dim);
  font-weight: 400;
  font-family:
    -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR",
    system-ui, sans-serif;
}

.md-pos {
  color: var(--fg-faint);
  font-size: 11px;
  font-style: italic;
}

.md-desc {
  color: var(--fg-dim);
  margin-top: 8px;
  font-size: 12.5px;
  line-height: 1.6;
  font-family:
    -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR",
    system-ui, sans-serif;
}

.meta-detail .md-example {
  color: var(--fg-faint);
  font-size: 12px;
  font-style: italic;
  border-top: 1px dashed rgba(255, 255, 255, 0.05);
  padding-top: 6px;
  margin-top: 4px;
}

.controls {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 14px 20px 22px;
}

.ctrl {
  background: var(--bg-soft);
  color: var(--fg);
  border: none;
  border-radius: var(--radius);
  padding: 14px 0;
  font-size: 18px;
  cursor: pointer;
  transition: background 180ms ease;
}

.ctrl:hover,
.ctrl:focus-visible {
  background: #1c1c1c;
}

.ctrl:active {
  background: #232323;
}

.ctrl.prev {
  justify-self: stretch;
}

.ctrl.next {
  justify-self: stretch;
}

.stage-control {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 10px;
  color: var(--fg-faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-align: center;
}

.stage-control label {
  pointer-events: none;
}

.stage-control select {
  background: var(--bg-soft);
  color: var(--fg);
  border: 1px solid var(--fg-faint);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' fill='none' stroke='%238a8a8a' stroke-width='1.4'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

/* ---------- chat ---------- */

.chat-fab {
  position: fixed;
  right: calc(20px + env(safe-area-inset-right));
  bottom: calc(96px + env(safe-area-inset-bottom));
  width: 52px;
  height: 52px;
  border-radius: 999px;
  background: #1a1a1a;
  color: var(--fg);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 22px;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
  z-index: 50;
  transition:
    background 160ms ease,
    transform 160ms ease;
}

.chat-fab:hover,
.chat-fab:focus-visible {
  background: #232323;
  transform: translateY(-1px);
  outline: none;
}

.chat-fab[hidden] {
  display: none;
}

.chat-panel {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  background: #0e0e0e;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  display: flex;
  flex-direction: column;
  max-height: 70vh;
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.6);
}

.chat-panel[hidden] {
  display: none;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.chat-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 500;
  color: var(--fg);
}

.chat-model {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--fg-faint);
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
}

.chat-close {
  background: transparent;
  border: none;
  color: var(--fg-dim);
  font-size: 16px;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 160ms ease;
}

.chat-close:hover,
.chat-close:focus-visible {
  background: rgba(255, 255, 255, 0.06);
  color: var(--fg);
  outline: none;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 13.5px;
  line-height: 1.6;
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo",
    "Noto Sans KR", system-ui, sans-serif;
}

.chat-msg {
  padding: 10px 14px;
  border-radius: 14px;
  max-width: 88%;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.chat-msg-system {
  align-self: center;
  background: transparent;
  color: var(--fg-faint);
  font-size: 11.5px;
  text-align: center;
  max-width: 100%;
  padding: 4px 8px;
  font-style: italic;
}

.chat-msg-user {
  align-self: flex-end;
  background: #2a2a2a;
  color: var(--fg);
}

.chat-msg-assistant {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.04);
  color: var(--fg);
}

.chat-msg-pending {
  color: var(--fg-faint);
  font-style: italic;
}

.chat-msg-error {
  color: rgba(255, 140, 140, 0.95);
  background: rgba(255, 120, 120, 0.08);
}

.chat-input-row {
  display: flex;
  gap: 8px;
  padding: 12px 14px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  align-items: flex-end;
}

.chat-input {
  flex: 1;
  background: var(--bg-soft);
  color: var(--fg);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13.5px;
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo",
    "Noto Sans KR", system-ui, sans-serif;
  resize: none;
  line-height: 1.5;
  max-height: 140px;
  min-height: 40px;
  transition: border-color 160ms ease;
}

.chat-input:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.2);
}

.chat-input::placeholder {
  color: var(--fg-faint);
}

.chat-send {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: var(--fg);
  color: var(--bg);
  border: none;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition:
    background 160ms ease,
    opacity 160ms ease;
}

.chat-send:hover,
.chat-send:focus-visible {
  background: #fff;
  outline: none;
}

.chat-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

@media (min-width: 700px) {
  .chat-panel {
    left: auto;
    right: 20px;
    bottom: 20px;
    width: 420px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.08);
  }
  .chat-fab {
    bottom: 24px;
  }
}

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

@media (min-width: 700px) {
  .card-area {
    max-width: 720px;
    margin: 0 auto;
    width: 100%;
  }
  .controls {
    max-width: 720px;
    margin: 0 auto;
    width: 100%;
  }
  .topbar {
    max-width: 720px;
    margin: 0 auto;
    width: 100%;
  }
}
