.app-header {
  border-bottom: 1px solid var(--border);
  background: rgba(244, 245, 241, 0.9);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.app-header .header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  gap: 1rem;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(240px, 320px) 1fr;
  gap: 1.5rem;
  padding: 2rem 1.5rem 4rem;
  max-width: 1400px;
  margin: 0 auto;
}

.narrow {
  max-width: 720px;
}

.form-grid {
  display: grid;
  gap: 0.8rem;
}

.form-grid input,
.form-grid select,
.case-list input,
.case-list select,
textarea {
  padding: 0.6rem 0.8rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
}

.case-list {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.2rem;
  box-shadow: var(--shadow);
  display: grid;
  gap: 1rem;
  height: fit-content;
}

.case-list-header h2 {
  margin: 0;
}

.case-items {
  display: grid;
  gap: 0.6rem;
}

.case-item {
  padding: 0.6rem 0.8rem;
  border-radius: 12px;
  border: 1px solid transparent;
  cursor: pointer;
  background: var(--surface-alt);
}

.case-item.active {
  border-color: var(--accent);
  background: #fff;
}

.case-detail {
  display: grid;
  gap: 1rem;
}

.case-header {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.2rem 1.5rem;
  box-shadow: var(--shadow);
}

.case-header-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  align-items: center;
}

.case-score {
  display: grid;
  justify-items: center;
  gap: 0.6rem;
}

.score-ring {
  width: 90px;
  height: 90px;
  border-radius: 999px;
  background: conic-gradient(var(--accent) calc(var(--p) * 1%), rgba(27, 94, 60, 0.12) 0);
  display: grid;
  place-items: center;
  position: relative;
}

.score-ring::after {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid rgba(27, 94, 60, 0.14);
}

.score-ring > * {
  position: relative;
  z-index: 1;
}

.score-value {
  font-weight: 800;
  font-size: 1.4rem;
  font-family: var(--font-display);
}

.score-label {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: -0.2rem;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.explain-details {
  display: none;
  border-top: 1px solid var(--border);
  margin-top: 0.8rem;
  padding-top: 0.8rem;
}

body.explain-mode .explain-details {
  display: block;
}

.mini-list {
  margin: 0.4rem 0 0;
  padding-left: 1.1rem;
}

.code-block {
  background: rgba(36, 54, 64, 0.08);
  border: 1px solid rgba(36, 54, 64, 0.15);
  padding: 0.8rem;
  border-radius: 12px;
  overflow: auto;
}

.case-header h2 {
  margin: 0;
}

.case-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  color: var(--muted);
  font-size: 0.9rem;
}

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

.app-tab {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  background: var(--surface);
  cursor: pointer;
  font-weight: 600;
}

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

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.panel-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.2rem 1.5rem;
  box-shadow: var(--shadow);
}

.panel-card h3 {
  margin-top: 0;
}

.inline-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 0.8rem;
}

.inline-actions button,
.inline-actions a {
  border: none;
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
}

.inline-actions .secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.list-grid {
  display: grid;
  gap: 0.6rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  background: rgba(27, 94, 60, 0.12);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-2);
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 1.2rem 0;
}

.notice {
  color: var(--muted);
  font-size: 0.9rem;
}

textarea {
  width: 100%;
  min-height: 160px;
}

.app-footer {
  padding: 2rem 1.5rem;
  text-align: center;
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 1.5rem;
  bottom: 1.5rem;
  background: #1b5e3c;
  color: #fff;
  padding: 0.8rem 1.2rem;
  border-radius: 999px;
  display: none;
  z-index: 80;
}

.toast.show {
  display: block;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .case-header-grid {
    grid-template-columns: 1fr;
    justify-items: start;
  }
}
