﻿:root {
  /* Clean neutral palette */
  --bg: #ffffff;
  --card: #ffffff;
  --fill: #e8eaee;
  --fill-soft: #f0f1f4;
  --border: #e6e8ec;
  --border-strong: #dde0e6;
  --separator: #eef0f3;

  --ink: #0e1116;
  --ink-2: #5b616e;
  --ink-3: #8a909c;

  --accent: #2f5bea;
  --accent-ring: rgba(47, 91, 234, 0.16);

  --hero-bg: #2b303b;
  --hero-ink: #ffffff;
  --hero-muted: #a9afbb;
  --hero-line: #3d4350;
  --hero-fill: #383e4a;

  --good: #6ee7a8;
  --good-soft: rgba(110, 231, 168, 0.16);
  --good-text: #15803d;
  --warn: #fdba74;
  --bad: #fca5a5;
  --bad-soft: rgba(252, 165, 165, 0.18);
  --bad-text: #b91c1c;

  --radius-xl: 24px;
  --radius-lg: 20px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --shadow-tab: 0 1px 2px rgba(14, 17, 22, 0.08), 0 4px 12px rgba(14, 17, 22, 0.06);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

html {
  -webkit-text-size-adjust: 100%;
}

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

button,
input,
select {
  font-family: inherit;
  color: inherit;
}

input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
}

/* Header: stays visible while scrolling */
.top-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--separator);
  padding-top: env(safe-area-inset-top);
}

.nav-inner {
  max-width: 640px;
  margin: 0 auto;
  padding: 14px 20px 12px;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "title reset"
    "tabs tabs";
  align-items: center;
  row-gap: 12px;
}

.app-title {
  grid-area: title;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.text-btn {
  grid-area: reset;
  width: 44px;
  height: 44px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-2);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.text-btn:hover {
  background: var(--fill);
  color: var(--ink);
}

/* Tabs */
.segmented-control {
  grid-area: tabs;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  background: var(--fill);
  border-radius: var(--radius-md);
}

.seg-btn {
  appearance: none;
  height: 56px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}

.seg-btn:hover {
  color: var(--ink);
}

.seg-btn.active {
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow-tab);
}

.seg-btn:focus-visible,
.pill-btn:focus-visible,
.text-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Layout */
.app-main {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 20px 32px;
}

.view[hidden] {
  display: none;
}

/* Hero card (dark result card) */
.hero-score {
  background: var(--hero-bg);
  color: var(--hero-ink);
  border-radius: var(--radius-xl);
  padding: 24px 22px 20px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hero-eyebrow {
  font-size: 13px;
  font-weight: 500;
  color: var(--hero-muted);
}

.hero-number {
  font-size: 72px;
  font-weight: 800;
  letter-spacing: -0.05em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--hero-ink);
}

.hero-score.pass .hero-number {
  color: var(--good);
}

.hero-score.warn .hero-number {
  color: var(--warn);
}

.hero-score.fail .hero-number {
  color: var(--bad);
}

.hero-meta {
  font-size: 14px;
  color: var(--hero-muted);
}

.hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.hero-pill {
  background: var(--hero-fill);
  color: var(--hero-ink);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
}

.round-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--hero-line);
  font-size: 13px;
  color: var(--hero-muted);
}

.round-bar .pill-group {
  background: var(--hero-fill);
  padding: 3px;
  border-radius: var(--radius-sm);
  gap: 2px;
}

.round-bar .pill-btn {
  min-width: 44px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--hero-muted);
  border-radius: 9px;
}

.round-bar .pill-btn:hover {
  color: var(--hero-ink);
}

.round-bar .pill-btn.active {
  background: #ffffff;
  color: #0e1116;
}

/* Points entry */
.points-entry {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 16px;
}

.points-field {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
}

.points-field input {
  width: 100%;
  min-width: 0;
  height: 64px;
  font-size: 28px;
  font-weight: 700;
  text-align: center;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  font-variant-numeric: tabular-nums;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.points-field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-ring);
}

.points-sep {
  padding-bottom: 22px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-3);
}

/* Sections & grouped lists */
.ios-section {
  margin-bottom: 20px;
}

.ios-section-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 10px;
}

.section-header-flex {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.section-header-flex .ios-section-title {
  margin-bottom: 0;
}

.ios-group {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.ios-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  padding: 10px 16px;
}

.ios-row[hidden] {
  display: none;
}

.ios-row:not(:last-child) {
  border-bottom: 1px solid var(--separator);
}

.ios-label {
  font-size: 15px;
}

.ios-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ios-input-right {
  width: 96px;
  height: 40px;
  padding: 0 12px;
  text-align: right;
  font-size: 17px;
  font-weight: 700;
  background: var(--fill-soft);
  border: 1px solid transparent;
  border-radius: 10px;
  font-variant-numeric: tabular-nums;
}

.ios-input-right[type="text"] {
  width: 180px;
  font-weight: 500;
}

.ios-input-right.small-num {
  width: 68px;
}

.ios-input-right:focus {
  outline: none;
  background: var(--card);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-ring);
}

/* Pills */
.pill-group {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill-btn {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--card);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.pill-btn:hover {
  border-color: var(--ink-3);
}

.pill-btn.active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}

/* Small stat cards */
.bento-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.bento-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.bento-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.bento-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
}

.bento-val {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.bento-sub {
  font-size: 12px;
  color: var(--ink-2);
}

/* Disclosure / table */
.ios-disclosure {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.ios-disclosure-summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  padding: 0 16px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.ios-disclosure-summary::-webkit-details-marker {
  display: none;
}

.disclosure-meta {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
}

.disclosure-body {
  border-top: 1px solid var(--separator);
  padding: 12px 16px 16px;
}

.disclosure-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--ink-2);
}

.table-scroll {
  max-height: 420px;
  overflow: auto;
}

.ios-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.ios-table th {
  position: sticky;
  top: 0;
  background: var(--card);
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  padding: 8px 6px;
  border-bottom: 1px solid var(--separator);
}

.ios-table td {
  padding: 8px 6px;
  border-bottom: 1px solid var(--separator);
}

.ios-table tr.highlight-row td {
  background: var(--accent-ring);
  font-weight: 700;
}

.grade-tag {
  display: inline-block;
  min-width: 44px;
  text-align: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-weight: 700;
}

.grade-tag.pass {
  background: var(--good-soft);
  color: var(--good-text);
}

.grade-tag.fail {
  background: var(--bad-soft);
  color: var(--bad-text);
}

/* Subjects */
.subjects-bar-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.subjects-pills {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  flex: 1;
  min-width: 0;
  scrollbar-width: none;
}

.subjects-pills::-webkit-scrollbar {
  display: none;
}

.subject-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--card);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.subject-pill.active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}

.subject-pill-avg {
  font-weight: 500;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

.subject-pill.active .subject-pill-avg {
  color: inherit;
  opacity: 0.7;
}

.subject-add-btn {
  flex-shrink: 0;
  height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px dashed var(--ink-3);
  background: transparent;
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.subject-add-btn:hover {
  color: var(--ink);
  border-color: var(--ink);
}

/* Grade rows */
.grade-item-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px 10px 16px;
}

.grade-item-row .mini-field {
  flex: 1;
}

.grade-item-row:not(:last-child) {
  border-bottom: 1px solid var(--separator);
}

.grade-desc-input {
  flex: 1;
  min-width: 0;
  height: 40px;
  border: none;
  background: transparent;
  font-size: 15px;
  font-weight: 500;
}

.grade-desc-input::placeholder {
  color: var(--ink-3);
}

.grade-desc-input:focus {
  outline: none;
}

.mini-field {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.mini-field span {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-2);
}

.mini-field input {
  width: 60px;
  height: 36px;
  text-align: center;
  font-size: 16px;
  font-weight: 700;
  background: var(--fill-soft);
  border: 1px solid transparent;
  border-radius: 10px;
  font-variant-numeric: tabular-nums;
}

.mini-field input:focus {
  outline: none;
  background: var(--card);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.del-circle-btn {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-3);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.del-circle-btn:hover {
  background: var(--bad-soft);
  color: var(--bad-text);
}

.ios-add-row-btn {
  width: 100%;
  height: 52px;
  margin-top: 10px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: #ffffff;
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: filter 0.15s;
}

.ios-add-row-btn:hover {
  filter: brightness(1.08);
}

.plus-icon {
  font-size: 18px;
}

.link-btn {
  border: none;
  background: transparent;
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
}

.link-select {
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--card);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.danger-link-btn {
  border: none;
  background: transparent;
  color: var(--bad-text);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
}

.danger-link-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Target tab */
.is-preset-row {
  flex-wrap: wrap;
  justify-content: flex-start;
}

.preset-hint {
  font-size: 13px;
  color: var(--ink-2);
}

.weight-control-wrap {
  flex-wrap: wrap;
  justify-content: flex-end;
}

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

.sim-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sim-grade {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
}

.sim-result {
  font-size: 18px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.sim-card.pass .sim-result {
  color: var(--good-text);
}

.sim-card.fail .sim-result {
  color: var(--bad-text);
}

@media (max-width: 420px) {
  .nav-inner,
  .app-main {
    padding-left: 16px;
    padding-right: 16px;
  }

  .hero-number {
    font-size: 64px;
  }

  .bento-val {
    font-size: 19px;
  }

  .ios-row {
    flex-wrap: wrap;
  }
}

h1.app-title {
  margin: 0;
}

.seo-info {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 16px 40px;
  color: var(--ink-3);
  font-size: 13px;
  line-height: 1.5;
}

.seo-info h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 6px;
}
