:root {
  --bg: #f7f1e6;
  --ink: #2d2a26;
  --muted: #746d64;
  --panel: #fffaf0;
  --line: #ddd1bf;
  --green: #25745c;
  --green-soft: #dceee6;
  --red: #b64b3e;
  --red-soft: #f4ded8;
  --blue-soft: #dce8f4;
  --shadow: 0 20px 45px rgba(62, 50, 36, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(255, 250, 240, 0.86), rgba(232, 241, 242, 0.72)),
    var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "YuGothic", "Noto Sans JP", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  touch-action: manipulation;
}

.app {
  width: min(900px, 100%);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 18px max(24px, env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin: 8px 0 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2rem, 7vw, 3.2rem);
  line-height: 1.08;
}

h2 {
  font-size: 1.1rem;
}

.today {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 22px rgba(62, 50, 36, 0.08);
}

.today span {
  font-size: 1.85rem;
  font-weight: 900;
}

.today small {
  color: var(--muted);
  font-weight: 800;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 5px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.72);
}

.tab {
  min-height: 48px;
  border: 0;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  font-weight: 900;
}

.tab.active {
  color: #fff;
  background: var(--ink);
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.stat {
  min-height: 72px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.stat strong {
  display: block;
  font-size: 1.65rem;
}

.stat span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.stat.good {
  background: var(--green-soft);
  border-color: rgba(37, 116, 92, 0.28);
}

.stat.hard {
  background: var(--red-soft);
  border-color: rgba(182, 75, 62, 0.25);
}

.toolbar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.secondary,
.primary,
.answer-button {
  min-height: 52px;
  border-radius: 8px;
  font-weight: 900;
}

.secondary {
  padding: 0 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
}

.primary {
  border: 0;
  background: var(--ink);
  color: #fff;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.hidden {
  display: none !important;
}

.empty-state {
  display: grid;
  gap: 6px;
  padding: 18px;
  margin: 10px 0 14px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.72);
}

.empty-state span,
.list-empty {
  color: var(--muted);
}

.practice {
  margin-bottom: 16px;
}

.flashcard {
  position: relative;
  display: grid;
  grid-template-rows: 1fr auto;
  place-items: center;
  width: 100%;
  min-height: clamp(300px, 52vh, 470px);
  padding: 44px 20px 34px;
  border: 2px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(220, 238, 230, 0.46)),
    var(--panel);
  box-shadow: var(--shadow);
}

.card-center {
  display: grid;
  gap: 22px;
  place-items: center;
  width: 100%;
}

.card-badge {
  position: absolute;
  top: 16px;
  left: 16px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
}

.reading,
.card-answer {
  display: block;
  width: 100%;
  overflow-wrap: anywhere;
  text-align: center;
  font-size: clamp(3.8rem, 14vw, 8rem);
  line-height: 1.08;
}

.reading {
  font-weight: 900;
}

.card-answer {
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", serif;
  font-weight: 900;
}

.card-prompt {
  align-self: end;
  color: var(--muted);
  font-weight: 800;
}

.actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.answer-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 64px;
  border: 0;
  color: #fff;
  font-size: 1.08rem;
}

.answer-button span {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
}

.answer-button.good {
  background: var(--green);
}

.answer-button.hard {
  background: var(--red);
}

.register {
  margin-top: 2px;
}

.word-section {
  margin-top: 18px;
}

.word-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 120px;
  gap: 10px;
  align-items: end;
  margin-top: 10px;
}

.word-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.bulk {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.bulk-title {
  margin: 0 0 6px;
  font-size: 1rem;
}

.bulk-hint {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.bulk-input {
  width: 100%;
  min-height: 150px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  line-height: 1.7;
  resize: vertical;
  margin-bottom: 10px;
}

.data-tools {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.file-input {
  display: none;
}

input {
  width: 100%;
  min-height: 52px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
}

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

.word-list {
  display: grid;
  gap: 8px;
}

.word-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.word-row.good {
  background: var(--green-soft);
  border-color: rgba(37, 116, 92, 0.28);
}

.word-row.hard {
  background: var(--red-soft);
  border-color: rgba(182, 75, 62, 0.25);
}

.word-main {
  flex: 1;
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.word-main strong {
  overflow-wrap: anywhere;
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", serif;
  font-size: 1.45rem;
}

.word-reading,
.word-main small {
  color: var(--muted);
  font-weight: 800;
}

.secondary.small {
  flex: 0 0 auto;
  min-height: 42px;
  padding: 0 12px;
}

.primary.small {
  flex: 0 0 auto;
  min-height: 42px;
  padding: 0 14px;
}

.word-actions {
  flex: 0 0 auto;
  display: flex;
  gap: 6px;
}

.word-edit {
  flex: 1;
  display: grid;
  gap: 8px;
  min-width: 0;
}

.word-edit input {
  min-height: 44px;
}

@media (max-width: 680px) {
  .app {
    padding-left: 12px;
    padding-right: 12px;
  }

  .today {
    width: 66px;
    height: 66px;
  }

  .stat {
    min-height: 66px;
    padding: 9px;
  }

  .stat strong {
    font-size: 1.35rem;
  }

  .mode-tabs,
  .toolbar,
  .data-tools,
  .word-form {
    grid-template-columns: 1fr;
  }

  .flashcard {
    min-height: 310px;
  }
}
