:root {
  color-scheme: light dark;
  --bg: #f4f6fb;
  --fg: #1f2a44;
  --accent: #2f6fed;
  --accent-light: rgba(47, 111, 237, 0.1);
  --border: rgba(31, 42, 68, 0.1);
  --surface: #ffffff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft JhengHei", "微軟正黑體", "PingFang TC", "蘋方-繁", "Heiti TC", "黑體-繁", "Noto Sans TC", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--fg);
  padding: 0 1.5rem 3rem;
}

.page-header {
  text-align: center;
  padding: 2rem 0 1rem;
}

.hamburger {
  position: absolute;
  left: 1rem;
  top: 1.25rem;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.mobile-nav {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: 260px;
  background: var(--surface);
  box-shadow: 0 20px 40px rgba(0,0,0,0.2);
  transform: translateX(-100%);
  transition: transform 0.2s ease-out;
  padding: 4rem 1rem 1rem;
  z-index: 1000;
}

.mobile-nav.open {
  transform: translateX(0);
}

.mobile-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.mobile-nav .nav-link {
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
  background: white;
}

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 900;
}

.layout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
  max-width: 1200px;
  margin: 0 auto;
}

[data-view] {
  display: none;
}

[data-view].active {
  display: block;
}

.card {
  background: var(--surface);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 600;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: 0.95rem;
}

.field.inline {
  flex-direction: row;
  align-items: center;
  gap: 0.75rem;
}

.field input[type="text"],
.field textarea,
.field select {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem;
  font-size: 1rem;
  font-family: inherit;
  color: var(--fg);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: inset 0 1px 3px rgba(31, 42, 68, 0.08);
}

.field textarea {
  resize: vertical;
}

.option {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-right: 1rem;
}

.actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

button,
label[role="button"] {
  border: none;
  border-radius: 999px;
  padding: 0.65rem 1.25rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

button.primary,
label[role="button"].primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 8px 18px rgba(47, 111, 237, 0.35);
}

button.ghost,
label[role="button"].ghost {
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--border);
}

#resetButton {
  border: 2px solid #000;
}

button:hover,
label[role="button"]:hover {
  transform: translateY(-1px);
}

button:active,
label[role="button"]:active {
  transform: translateY(0);
}

.hint {
  font-size: 0.85rem;
  color: rgba(31, 42, 68, 0.6);
  margin: 0;
}

.saved-list ul {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.saved-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  background: var(--accent-light);
}

.saved-item__info {
  display: flex;
  flex-direction: column;
}

.saved-item__title {
  font-weight: 600;
}

.saved-item__meta {
  font-size: 0.8rem;
  color: rgba(31, 42, 68, 0.6);
}

.saved-item button {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
}

.result {
  min-height: 120px;
  border-radius: 12px;
  background: rgba(47, 111, 237, 0.05);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  font-size: 0.95rem;
}

.result--empty {
  opacity: 0.6;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.char-result-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.char-result {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  background: white;
  border: 1px solid rgba(47, 111, 237, 0.12);
}

.char-result__char {
  font-weight: 600;
  font-size: 1.1rem;
}

.char-result__status {
  color: rgba(31, 42, 68, 0.7);
}

.status-match {
  color: #1f7a32;
}

.status-mismatch {
  color: #b02e2b;
}

.status-missing,
.status-extra {
  color: rgba(31, 42, 68, 0.7);
}

.full-result {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: white;
  border: 1px solid rgba(47, 111, 237, 0.12);
  border-radius: 10px;
  padding: 0.8rem;
}

.full-result p {
  margin: 0;
  line-height: 1.5;
  word-break: break-all;
}

.diff-list {
  margin: 0.2rem 0 0;
  padding-left: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.diff-list li {
  line-height: 1.4;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  background: rgba(31, 42, 68, 0.08);
  color: rgba(31, 42, 68, 0.8);
}

.badge--success {
  background: rgba(47, 179, 68, 0.15);
  color: #1f7a32;
}

.badge--error {
  background: rgba(237, 80, 74, 0.15);
  color: #b02e2b;
}

.hint strong {
  font-weight: 600;
}

@media (max-width: 600px) {
  body {
    padding: 0 1rem 2rem;
  }

  .card {
    padding: 1.25rem;
  }

  .page-header {
    position: sticky;
    top: 0;
    background: var(--bg);
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
    z-index: 1100;
  }

  .hamburger {
    display: inline-flex;
  }

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