:root {
  color-scheme: light;
  --ink: #17201d;
  --muted: #62706a;
  --paper: #f7f4ec;
  --surface: #ffffff;
  --surface-soft: #fbfaf6;
  --line: #d9ded6;
  --teal: #126b64;
  --red: #b33d32;
  --gold: #d99d2b;
  --shadow: 0 18px 46px rgba(23, 32, 29, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  min-height: 100vh;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  --ink: #17201d;
  --muted: #62706a;
  --paper: #f7f4ec;
  --surface: #ffffff;
  --surface-soft: #fbfaf6;
  --line: #d9ded6;
  --teal: #126b64;
  --red: #b33d32;
  --gold: #d99d2b;
  --shadow: 0 18px 46px rgba(23, 32, 29, 0.1);
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  width: min(1240px, calc(100vw - 32px));
  max-width: none;
  min-height: min(100vh, 760px);
  margin-left: 50%;
  transform: translateX(-50%);
  overflow: visible;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  text-align: left;
  isolation: isolate;
}

.app-shell,
.entry-content > .app-shell,
.wp-block-shortcode > .app-shell {
  position: relative;
  left: 50%;
  right: 50%;
  width: min(1240px, calc(100vw - 32px));
  margin-left: max(-620px, calc(-50vw + 16px));
  margin-right: max(-620px, calc(-50vw + 16px));
  transform: none;
}

.app-shell *,
.app-shell *::before,
.app-shell *::after {
  box-sizing: border-box;
}

.app-shell button,
.app-shell input,
.app-shell select,
.app-shell textarea {
  font: inherit;
}

.app-shell button {
  cursor: pointer;
  letter-spacing: 0;
  text-transform: none;
}

.wp-block-shortcode:has(.app-shell),
.entry-content:has(.app-shell),
.wp-site-blocks:has(.app-shell) {
  max-width: none;
  overflow: visible;
}

.app-shell main,
.app-shell .view,
.app-shell .study-layout {
  min-width: 0;
  max-width: none;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 14px;
  min-height: min(100vh, 760px);
  align-content: start;
  padding: 16px 12px;
  border-right: 1px solid var(--line);
  background: rgba(247, 244, 236, 0.94);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--red);
  color: #fff;
  font-family: "Noto Sans JP", sans-serif;
  font-weight: 900;
}

.pool-tabs,
.mode-switch {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px;
  border: 1px solid rgba(23, 32, 29, 0.14);
  border-radius: 8px;
  background: var(--surface);
}

.nav-tabs {
  display: grid;
  align-content: start;
  gap: 8px;
}

.auth-section {
  padding: 4px 0;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  font-weight: 700;
}

.user-info[hidden] {
  display: none;
}

.user-avatar {
  border-radius: 50%;
}

.google-sign-in {
  width: 100%;
}

.sidebar-controls {
  display: grid;
  gap: 12px;
  min-width: 0;
  align-content: start;
}

.sidebar-block {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.sidebar-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav-tab,
.pool-tab,
.mode-button {
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  padding: 0 13px;
  background: transparent;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.nav-tab {
  width: 100%;
  border: 1px solid rgba(23, 32, 29, 0.12);
  background: var(--surface);
  text-align: left;
}

.sidebar-controls .pool-tabs,
.sidebar-controls .mode-switch {
  display: grid;
  width: 100%;
}

.sidebar-controls .pool-tab,
.sidebar-controls .mode-button {
  width: 100%;
  text-align: left;
}

.nav-tab.is-active,
.pool-tab.is-active,
.mode-button.is-active {
  background: var(--ink);
  color: #fff;
}

.mode-button:disabled {
  cursor: not-allowed;
  color: #8e9893;
}

.app-shell main {
  width: min(1160px, calc(100% - 28px));
  margin: 0 auto;
}

.view {
  display: none;
  padding: 24px 0 52px;
}

.view.is-active {
  display: block;
}

#practiceView.view.is-active {
  display: block;
  min-height: 0;
  overflow: visible;
  padding: 14px 0 28px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.page-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 22px;
  margin-bottom: 12px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--red);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.app-shell h1,
.app-shell h2,
.app-shell p {
  margin-top: 0;
}

.app-shell h1 {
  margin-bottom: 0;
  max-width: 780px;
  font-size: clamp(1.55rem, 3vw, 2.65rem);
  line-height: 1;
  letter-spacing: 0;
}

.app-shell h2 {
  margin-bottom: 0;
  font-size: clamp(1.4rem, 2vw, 1.9rem);
  line-height: 1.1;
}

.status-band {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
  box-shadow: var(--shadow);
}

.status-band > div {
  min-width: 0;
  padding: 10px 14px;
  background: var(--surface);
}

.status-label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.pool-tabs {
  width: fit-content;
  margin-bottom: 8px;
}

.mode-switch {
  width: fit-content;
  margin-bottom: 8px;
}

.review-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1.35;
}

.study-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 340px);
  gap: 14px;
  align-items: start;
  height: auto;
  min-height: 0;
}

.flashcard,
.notes-panel,
.login-panel,
.completion-card,
.due-section,
.tracker-table {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.flashcard {
  min-height: 0;
  padding: clamp(14px, 2vw, 22px);
  overflow: visible;
}

.notes-panel {
  display: grid;
  gap: 10px;
  align-content: start;
  min-height: 0;
  padding: 14px;
  overflow: visible;
}

.card-meta {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
  text-transform: uppercase;
}

.field-label {
  display: block;
  margin: 10px 0 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.text-field,
.answer-input,
.select-input,
.note-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--ink);
}

.text-field {
  min-height: 46px;
  display: flex;
  align-items: center;
  padding: 10px 12px;
  font-size: 1.2rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.japanese-field {
  min-height: clamp(88px, 18vh, 138px);
  justify-content: center;
  font-family: "Noto Sans JP", sans-serif;
  font-size: clamp(3rem, 8vw, 6.2rem);
  line-height: 1;
  text-align: center;
}

.japanese-answer {
  font-family: "Noto Sans JP", sans-serif;
  font-size: clamp(2rem, 6vw, 4rem);
}

.text-field[hidden] {
  display: none;
}

.answer-field[hidden] {
  display: none;
}

.answer-input,
.select-input,
.note-input {
  padding: 10px 12px;
  outline: none;
}

.answer-input:focus,
.select-input:focus,
.note-input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(18, 107, 100, 0.12);
}

.answer-feedback {
  margin: 8px 0 0;
  min-height: 22px;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 700;
}

.answer-feedback.is-correct {
  color: var(--teal);
}

.answer-feedback.is-incorrect {
  color: var(--red);
}

.action-row,
.quality-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

.primary-action,
.secondary-action,
.text-action {
  min-height: 38px;
  border-radius: 8px;
  padding: 0 18px;
  font-weight: 800;
}

.primary-action {
  border: 1px solid var(--teal);
  background: var(--teal);
  color: #fff;
}

.secondary-action {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.text-action {
  border: 0;
  background: transparent;
  color: var(--red);
  padding: 0;
}

.quality-row button {
  flex: 1 1 95px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--ink);
  font-weight: 800;
}

.quality-row button:hover {
  border-color: var(--teal);
}

.note-list {
  display: grid;
  gap: 8px;
  margin: 0;
}

.note-list div {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.note-list dt {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.note-list dd {
  margin: 0;
  line-height: 1.36;
}

.note-list div[hidden] {
  display: none;
}

.limit-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.45;
}

.due-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.due-section {
  padding: 18px;
}

.due-section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.due-section-heading span,
.empty-note {
  color: var(--muted);
  font-weight: 700;
}

.empty-note {
  margin-bottom: 0;
}

.due-list {
  display: grid;
  gap: 10px;
}

.due-item {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--ink);
  text-align: left;
}

.due-front {
  display: grid;
  place-items: center;
  min-height: 54px;
  border-radius: 8px;
  background: var(--gold);
  color: #261c08;
  font-family: "Noto Sans JP", sans-serif;
  font-size: 1.25rem;
  font-weight: 900;
}

.due-item strong,
.due-item span,
.due-item small {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}

.due-item span span,
.due-item small {
  color: var(--muted);
  font-size: 0.86rem;
}

.browser-controls {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) repeat(3, minmax(150px, 0.7fr));
  gap: 14px;
  align-items: end;
  margin-bottom: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.browser-controls .field-label {
  margin-top: 0;
}

.browser-count {
  margin-bottom: 14px;
  color: var(--muted);
  font-weight: 800;
}

.browser-results {
  display: grid;
  gap: 10px;
}

.dev-card-panel {
  display: grid;
  gap: 18px;
  margin-top: 24px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

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

.dev-card-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.dev-card-form .field-label {
  margin-top: 0;
}

.wide-field,
.dev-actions,
.export-output {
  grid-column: 1 / -1;
}

.japanese-entry {
  font-family: "Noto Sans JP", sans-serif;
}

.dev-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.export-output {
  font-family: Consolas, "Courier New", monospace;
  min-height: 150px;
}

.browser-item {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  width: 100%;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  box-shadow: 0 8px 26px rgba(23, 32, 29, 0.05);
}

.browser-front {
  display: grid;
  place-items: center;
  min-height: 58px;
  border-radius: 8px;
  background: var(--gold);
  color: #261c08;
  font-family: "Noto Sans JP", sans-serif;
  font-size: 1.3rem;
  font-weight: 900;
}

.browser-main strong,
.browser-main span,
.browser-main small {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}

.browser-main span,
.browser-main small {
  color: var(--muted);
}

.browser-main small {
  margin-top: 3px;
  font-size: 0.86rem;
}

.completion-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.completion-card {
  padding: 20px;
}

.completion-card h2 {
  margin-bottom: 12px;
}

.progress-bar {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8e3d8;
}

.progress-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--teal);
}

.completion-card p {
  margin: 12px 0 0;
  color: var(--muted);
}

.tracker-table {
  overflow: hidden;
}

.tracker-row {
  display: grid;
  grid-template-columns: 1.1fr repeat(6, minmax(70px, 0.7fr));
  gap: 1px;
  background: var(--line);
}

.tracker-row > span {
  min-width: 0;
  padding: 14px;
  background: var(--surface);
  overflow-wrap: anywhere;
}

.tracker-row.header span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

@media (max-width: 900px) {
  .app-shell {
    display: block;
  }

  .app-header,
  .page-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .app-header {
    position: sticky;
    height: auto;
    min-height: 0;
    gap: 12px;
    padding: 10px 14px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav-tabs {
    display: flex;
    width: 100%;
    overflow-x: auto;
  }

  .nav-tab {
    text-align: center;
  }

  .pool-tabs,
  .mode-switch {
    width: 100%;
    overflow-x: auto;
  }

  .pool-tab,
  .mode-button {
    flex: 1 0 max-content;
  }

  .nav-tab {
    flex: 1 0 max-content;
  }

  #practiceView.view.is-active {
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  .study-layout,
  .status-band,
  .due-grid,
  .browser-controls,
  .dev-card-form,
  .completion-grid {
    grid-template-columns: 1fr;
  }

  .tracker-row {
    grid-template-columns: 1fr 1fr;
  }

  .tracker-row.header {
    display: none;
  }
}

@media (max-width: 520px) {
  main {
    width: min(100% - 24px, 1180px);
  }

  .view {
    padding-top: 28px;
  }

  h1 {
    font-size: 2.45rem;
  }

  .flashcard {
    min-height: auto;
  }
}

.app-shell main {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
}

.app-shell .view {
  display: none !important;
  visibility: visible !important;
  opacity: 1 !important;
  position: relative !important;
}

.app-shell .view.is-active,
.app-shell #practiceView.view.is-active {
  display: block !important;
}

.app-shell .study-layout {
  display: grid !important;
  visibility: visible !important;
  opacity: 1 !important;
}

.app-shell .flashcard,
.app-shell .notes-panel {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  position: relative !important;
}

.app-shell .notes-panel {
  display: grid !important;
}
