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

:root {
  --font-main: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Fira Mono", "Roboto Mono", monospace;
  --radius: 8px;
  --transition: 0.2s ease;
}

[data-theme="dark"] {
  --bg: #0d1117;
  --bg-card: #161b22;
  --bg-hover: #1c2333;
  --bg-input: #21262d;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --text-dim: #6e7681;
  --accent: #58a6ff;
  --accent-dim: #1f6feb33;
  --green: #3fb950;
  --green-dim: #23863633;
  --red: #f85149;
  --red-dim: #da363333;
  --yellow: #d29922;
  --yellow-dim: #bb800933;
  --orange: #db6d28;
  --purple: #bc8cff;
}

[data-theme="light"] {
  --bg: #f6f8fa;
  --bg-card: #ffffff;
  --bg-hover: #f3f4f6;
  --bg-input: #f6f8fa;
  --border: #d0d7de;
  --text: #1f2328;
  --text-muted: #656d76;
  --text-dim: #8b949e;
  --accent: #0969da;
  --accent-dim: #0969da1a;
  --green: #1a7f37;
  --green-dim: #1a7f3715;
  --red: #cf222e;
  --red-dim: #cf222e15;
  --yellow: #9a6700;
  --yellow-dim: #9a670015;
  --orange: #bc4c00;
  --purple: #8250df;
}

body {
  font-family: var(--font-main);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

.container {
  max-width: 860px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

/* Header */
header {
  text-align: center;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

header h1 {
  font-size: 1.9rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
  line-height: 1.25;
  max-width: 680px;
  margin-left: auto;
  margin-right: auto;
}

header h1 span {
  color: var(--accent);
  display: block;
  margin-top: 0.15rem;
}

header .subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  max-width: 560px;
  margin: 0 auto;
}

/* Authority Banner */
.authority-banner {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  padding: 0.9rem 1.25rem;
  margin-bottom: 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.authority-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  text-align: center;
  min-width: 140px;
}

.authority-item strong {
  font-weight: 600;
  color: var(--accent);
  font-size: 0.95rem;
  letter-spacing: -0.01em;
}

.authority-item span {
  color: var(--text-muted);
  font-size: 0.78rem;
}

@media (max-width: 640px) {
  .authority-banner {
    gap: 0.9rem;
    padding: 0.75rem 0.85rem;
  }

  .authority-item {
    min-width: 0;
  }

  .authority-item strong {
    font-size: 0.85rem;
  }

  .authority-item span {
    font-size: 0.72rem;
  }
}

/* Guide Navigation */
.guide-nav {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.guide-nav-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.guide-nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.4rem 0.85rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid transparent;
  border-radius: 20px;
  text-decoration: none;
  transition: all var(--transition);
}

.guide-nav-link:hover {
  background: var(--accent);
  color: #fff;
}

.guide-nav-link.active {
  background: var(--accent);
  color: #fff;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 1rem;
  transition: color var(--transition);
}

.back-link:hover {
  text-decoration: underline;
}

/* Toolbar */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.toolbar-left {
  display: flex;
  gap: 0.5rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.9rem;
  font-size: 0.82rem;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font-main);
}

.btn:hover {
  background: var(--bg-hover);
  color: var(--text);
  border-color: var(--text-dim);
}

.btn-danger {
  color: var(--red);
}

.btn-danger:hover {
  background: var(--red-dim);
  border-color: var(--red);
  color: var(--red);
}

#theme-toggle {
  font-size: 1.2rem;
  border: none;
  background: none;
  cursor: pointer;
  padding: 0.3rem;
}

/* Overall progress */
.overall-progress {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.overall-progress-label {
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
  color: var(--text-muted);
}

.overall-progress .progress-bar-track {
  flex: 1;
}

.overall-progress .progress-bar-text {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}

/* Progress bars */
.progress-bar-track {
  height: 6px;
  background: var(--bg-input);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--green);
  border-radius: 3px;
  transition: width 0.4s ease;
  min-width: 0;
}

.progress-bar-text {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-family: var(--font-mono);
}

/* Phase */
.phase {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1rem;
  overflow: hidden;
}

.phase-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  cursor: pointer;
  user-select: none;
  transition: background var(--transition);
}

.phase-header:hover {
  background: var(--bg-hover);
}

.phase-header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.phase-chevron {
  color: var(--text-dim);
  font-size: 0.75rem;
  transition: transform var(--transition);
  flex-shrink: 0;
}

.phase-title {
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.3;
}

.phase-timeline {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.phase-completion {
  font-size: 0.8rem;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--text-muted);
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  background: var(--bg-input);
}

.phase-completion.complete {
  background: var(--green-dim);
  color: var(--green);
}

.phase-progress-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1.25rem 0.75rem;
}

.phase-progress-bar .progress-bar-track {
  flex: 1;
}

/* Phase body */
.phase-body {
  padding: 0 1.25rem 1rem;
  transition: max-height 0.3s ease;
}

.phase-body.collapsed {
  display: none;
}

/* Section */
.section {
  margin-bottom: 1.25rem;
}

.section:last-child {
  margin-bottom: 0;
}

.section-title {
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin-bottom: 0.5rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
}

/* Items */
.items {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background var(--transition);
}

.item:hover {
  background: var(--bg-hover);
}

.item.checked {
  opacity: 0.55;
}

.item.checked .item-text {
  text-decoration: line-through;
  text-decoration-color: var(--text-dim);
}

.item input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  min-width: 18px;
  border: 2px solid var(--border);
  border-radius: 4px;
  background: var(--bg-input);
  cursor: pointer;
  transition: all var(--transition);
  margin-top: 2px;
  position: relative;
}

.item input[type="checkbox"]:checked {
  background: var(--green);
  border-color: var(--green);
}

.item input[type="checkbox"]:checked::after {
  content: "\2713";
  position: absolute;
  top: -1px;
  left: 2px;
  font-size: 12px;
  font-weight: 700;
  color: white;
}

.item input[type="checkbox"]:hover {
  border-color: var(--accent);
}

.item-content {
  flex: 1;
  min-width: 0;
}

.item-text {
  font-size: 0.9rem;
  line-height: 1.45;
}

.item-meta {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.25rem;
  flex-wrap: wrap;
}

.priority {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.priority-critical {
  background: var(--red-dim);
  color: var(--red);
}

.priority-important {
  background: var(--yellow-dim);
  color: var(--yellow);
}

.priority-nice {
  background: var(--green-dim);
  color: var(--green);
}

.category {
  font-size: 0.7rem;
  color: var(--text-dim);
  padding: 0.1rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.item-note {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
  padding-left: 0.1rem;
  line-height: 1.4;
}

/* Footer */
footer {
  text-align: center;
  padding: 2rem 0 1rem;
  color: var(--text-dim);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
  margin-top: 2rem;
}

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

footer a:hover {
  text-decoration: underline;
}

/* Item Info Badge */
.item-info-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  font-size: 0.55rem;
  font-weight: 700;
  font-style: italic;
  font-family: Georgia, "Times New Roman", serif;
  border-radius: 50%;
  background: var(--accent-dim);
  color: var(--accent);
  cursor: help;
  flex-shrink: 0;
  transition: all var(--transition);
  user-select: none;
}

.item:hover .item-info-badge {
  background: var(--accent);
  color: #fff;
}

/* Item Popover */
.item-popover {
  position: fixed;
  z-index: 1000;
  max-width: 380px;
  min-width: 240px;
  padding: 0.85rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, visibility 0.15s ease;
  pointer-events: none;
}

.item-popover.visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.popover-detail {
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--text);
  margin-bottom: 0.6rem;
}

.popover-hints-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin-bottom: 0.35rem;
}

.popover-hints ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.popover-hints li {
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--text-muted);
  padding-left: 1rem;
  position: relative;
}

.popover-hints li::before {
  content: "\2022";
  position: absolute;
  left: 0.1rem;
  color: var(--accent);
  font-weight: 700;
}

/* Personalize Panel */
.personalize {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
  overflow: hidden;
}

.personalize-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.75rem 1.25rem;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-main);
  color: var(--text);
  transition: background var(--transition);
}

.personalize-header:hover {
  background: var(--bg-hover);
}

.personalize-title {
  font-size: 0.85rem;
  font-weight: 600;
}

.personalize-badge {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.personalize-chevron {
  margin-left: auto;
  color: var(--text-dim);
  font-size: 0.7rem;
  transition: transform var(--transition);
}

.personalize-body {
  padding: 0 1.25rem 1rem;
}

.personalize-body.collapsed {
  display: none;
}

.filter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.filter-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background var(--transition);
}

.filter-toggle:hover {
  background: var(--bg-hover);
}

.filter-label {
  font-size: 0.85rem;
  line-height: 1.3;
}

.filter-toggle input[type="checkbox"] {
  display: none;
}

.toggle-switch {
  position: relative;
  width: 36px;
  height: 20px;
  min-width: 36px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: all var(--transition);
}

.toggle-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: var(--text-dim);
  border-radius: 50%;
  transition: all var(--transition);
}

.filter-toggle input:checked + .toggle-switch {
  background: var(--green);
  border-color: var(--green);
}

.filter-toggle input:checked + .toggle-switch::after {
  left: 18px;
  background: white;
}

/* Print */
@media print {
  body { background: white; color: black; }
  .toolbar, #theme-toggle, footer, .guide-nav, .personalize, .item-popover, .item-info-badge { display: none; }
  .phase { break-inside: avoid; border: 1px solid #ccc; }
  .phase-body.collapsed { display: block !important; }
  .item.checked { opacity: 0.5; }
  .overall-progress { border: 1px solid #ccc; }
  .progress-bar-track { background: #eee; }
  .progress-bar-fill { background: #333; }
}

/* Responsive */
@media (max-width: 640px) {
  .container {
    padding: 1rem 1rem 3rem;
  }

  header h1 {
    font-size: 1.4rem;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-left {
    justify-content: center;
  }

  .guide-nav {
    justify-content: center;
  }

  .guide-nav-label {
    width: 100%;
    text-align: center;
  }

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

  .overall-progress {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .phase-header {
    padding: 0.75rem 1rem;
  }

  .phase-title {
    font-size: 0.95rem;
  }

  .item {
    padding: 0.5rem;
  }

  .item-text {
    font-size: 0.85rem;
  }
}
