:root {
  color-scheme: light;
}

html[data-theme="wamodern"] {
  --bg: #f4ece0;
  --section: #efe6d6;
  --surface: #fbf7ef;
  --text: #2b2521;
  --secondary: #5a4a3a;
  --muted: rgba(43, 37, 33, 0.62);
  --line: rgba(43, 37, 33, 0.18);
  --accent: #b5482e;
  --accent-2: #2f5f6f;
  --accent-3: #677b45;
  --badge-bg: #b5482e;
  --badge-text: #fff8ee;
  --shadow: 0 8px 18px rgba(43, 37, 33, 0.06);
  --radius: 6px;
  --heading-font: "Shippori Mincho", "Noto Serif JP", serif;
  --body-font: "Noto Sans JP", system-ui, sans-serif;
  --link: #8e3522;
}

html[data-theme="wpstyle"] {
  --bg: #ffffff;
  --section: #f7f7f7;
  --surface: #ffffff;
  --text: #333333;
  --secondary: #666666;
  --muted: #777777;
  --line: #e3e3e3;
  --accent: #1967d2;
  --accent-2: #1967d2;
  --accent-3: #666666;
  --badge-bg: #f2f2f2;
  --badge-text: #555555;
  --shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
  --radius: 4px;
  --heading-font: "Noto Sans JP", system-ui, sans-serif;
  --body-font: "Noto Sans JP", system-ui, sans-serif;
  --link: #1a0dab;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 18px 18px, rgba(43, 37, 33, 0.025) 1px, transparent 1px),
    var(--bg);
  background-size: 36px 36px, auto;
  color: var(--text);
  font-family: var(--body-font);
  font-size: 16px;
  line-height: 1.7;
}

html[data-theme="wpstyle"] body {
  background: var(--bg);
}

a {
  color: var(--link);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 0.18em;
}

button,
select,
input {
  font: inherit;
}

.site-header {
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 88%, #fff);
  position: sticky;
  top: 0;
  z-index: 2;
}

.header-inner {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin: 0 auto;
  max-width: 1120px;
  padding: 14px 18px;
}

.brand {
  color: var(--text);
  font-family: var(--heading-font);
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.3;
}

.header-nav {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  justify-content: flex-end;
}

.theme-toggle {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  min-height: 36px;
  padding: 5px 12px;
}

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

.app {
  margin: 0 auto;
  max-width: 1120px;
  min-height: calc(100vh - 140px);
  padding: 28px 18px 40px;
}

.site-footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
  padding: 18px;
  text-align: center;
}

.page-head {
  display: grid;
  gap: 8px;
  margin-bottom: 22px;
}

.eyebrow {
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0;
}

h1,
h2,
h3 {
  font-family: var(--heading-font);
  letter-spacing: 0;
  line-height: 1.35;
  margin: 0;
}

h1 {
  font-size: clamp(1.8rem, 1.5rem + 1.3vw, 2.8rem);
}

h2 {
  font-size: 1.35rem;
}

.summary {
  color: var(--secondary);
  margin: 0;
}

.index-search {
  display: grid;
  gap: 5px;
  margin: 18px 0 6px;
  max-width: 520px;
}

.index-search span {
  color: var(--secondary);
  font-size: 0.86rem;
  font-weight: 700;
}

.index-search input {
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--text);
  border-radius: 0;
  color: var(--text);
  min-height: 40px;
  outline: 0;
  padding: 6px 0;
}

.index-search input:focus {
  border-bottom-color: var(--accent);
  box-shadow: 0 1px 0 var(--accent);
}

.search-count {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 8px;
}

.jump-nav {
  background: var(--section);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0 24px;
  padding: 12px;
}

.jump-nav button {
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  min-width: 2.2em;
  padding: 3px 8px;
  text-align: center;
}

.jump-nav button:hover {
  border-color: var(--accent);
  text-decoration: none;
}

.title-index {
  display: grid;
  gap: 24px;
}

.fav-title-section,
.fav-chip-section,
.fav-deck-section {
  display: grid;
  gap: 12px;
  margin: 0 0 24px;
}

.kana-section {
  background: color-mix(in srgb, var(--section) 68%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

.kana-section h2 {
  border-bottom: 1px solid var(--line);
  color: var(--accent-2);
  margin-bottom: 6px;
  padding-bottom: 8px;
}

.title-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.title-row {
  align-items: center;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  display: flex;
  gap: 10px;
  min-height: 48px;
  padding: 9px 4px;
}

.title-link {
  align-items: center;
  color: var(--text);
  display: flex;
  flex: 1 1 auto;
  gap: 10px;
  justify-content: space-between;
  min-width: 0;
}

.title-name {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.title-name small,
.deck-title small,
.title-chip small {
  color: var(--muted);
  display: block;
  font-size: 0.78em;
  font-weight: 400;
}

.title-row.is-empty {
  opacity: 0.48;
}

.fav-button {
  background: transparent;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  flex: 0 0 auto;
  font-size: 1.28rem;
  line-height: 1;
  min-height: 32px;
  min-width: 32px;
  padding: 0;
}

.fav-button.is-active {
  color: var(--accent);
}

.fav-button:hover {
  color: var(--accent);
}

.count-badge {
  background: var(--badge-bg);
  border-radius: 3px;
  color: var(--badge-text);
  display: inline-block;
  flex: 0 0 auto;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
  min-width: 3.5em;
  padding: 5px 7px;
  text-align: center;
}

html[data-theme="wpstyle"] .count-badge {
  border: 1px solid #dddddd;
  box-shadow: none;
}

.toolbar {
  align-items: end;
  background: var(--section);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(180px, 1fr) repeat(2, minmax(140px, 180px));
  margin: 0 0 18px;
  padding: 14px;
}

.field {
  display: grid;
  gap: 4px;
}

.field span {
  color: var(--secondary);
  font-size: 0.85rem;
  font-weight: 700;
}

.field select,
.field input {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  min-height: 40px;
  padding: 7px 9px;
  width: 100%;
}

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

.deck-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 0;
  overflow: hidden;
}

.thumb-wrap {
  align-items: center;
  aspect-ratio: 4 / 3;
  background: var(--section);
  display: flex;
  justify-content: center;
}

.thumb-wrap img {
  display: block;
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.thumb-wrap.is-broken::after {
  color: var(--muted);
  content: attr(data-label);
  font-size: 0.9rem;
}

.thumb-wrap.is-broken img {
  display: none;
}

.deck-body {
  display: grid;
  gap: 6px;
  padding: 12px;
}

.deck-actions {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.report-link {
  background: transparent;
  border: 0;
  color: var(--link);
  cursor: pointer;
  font-size: 0.84rem;
  padding: 0;
  text-align: right;
}

.report-link:hover {
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 0.18em;
}

.deck-title {
  display: grid;
  gap: 1px;
}

.deck-meta {
  color: var(--secondary);
  display: flex;
  flex-wrap: wrap;
  font-size: 0.88rem;
  gap: 6px 10px;
}

.deck-text {
  color: var(--text);
  display: -webkit-box;
  font-size: 0.92rem;
  margin: 0;
  min-height: 3.2em;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.empty-state {
  background: var(--section);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--secondary);
  padding: 24px;
}

.back-link {
  display: inline-block;
  margin-bottom: 14px;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.title-chip {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  display: inline-grid;
  line-height: 1.35;
  padding: 7px 10px;
}

.modal {
  align-items: center;
  background: rgba(43, 37, 33, 0.36);
  bottom: 0;
  display: flex;
  justify-content: center;
  left: 0;
  padding: 18px;
  position: fixed;
  right: 0;
  top: 0;
  z-index: 5;
}

.modal[hidden] {
  display: none;
}

.modal-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
  max-width: 620px;
  padding: 18px;
  position: relative;
  width: min(100%, 620px);
}

.modal-close {
  background: transparent;
  border: 0;
  color: var(--secondary);
  cursor: pointer;
  font-size: 1.4rem;
  line-height: 1;
  position: absolute;
  right: 12px;
  top: 10px;
}

.report-current {
  display: grid;
  gap: 12px;
  grid-template-columns: 120px 1fr;
}

.report-current img {
  aspect-ratio: 4 / 3;
  background: var(--section);
  border: 1px solid var(--line);
  object-fit: cover;
  width: 100%;
}

textarea {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  padding: 7px 9px;
  resize: vertical;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.modal-actions button {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  min-height: 36px;
  padding: 5px 12px;
}

.modal-actions .primary-action {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  bottom: 18px;
  box-shadow: var(--shadow);
  color: var(--text);
  left: 50%;
  max-width: calc(100vw - 36px);
  padding: 10px 14px;
  position: fixed;
  transform: translateX(-50%);
  z-index: 6;
}

html[data-theme="wpstyle"] h1,
html[data-theme="wpstyle"] h2,
html[data-theme="wpstyle"] h3,
html[data-theme="wpstyle"] .brand {
  font-family: var(--body-font);
}

@media (max-width: 860px) {
  .deck-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .toolbar {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .header-inner {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-nav {
    justify-content: flex-start;
  }

  .title-list,
  .deck-grid {
    grid-template-columns: 1fr;
  }
}
