/* ==========================================================================
   Components (v2)
   ========================================================================== */

/* ---- Buttons ---------------------------------------------------------- */
.btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--ink);
  --btn-bd: var(--line-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  max-width: 100%;
  padding: 10px 18px;
  border: 1.5px solid var(--btn-bd);
  border-radius: 999px;
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-weight: 650;
  font-size: 15px;
  line-height: 1.2;
  white-space: nowrap;
  transition: background 0.18s var(--ease), border-color 0.18s, color 0.18s, transform 0.15s var(--spring), box-shadow 0.2s;
  user-select: none;
}
.btn:hover { border-color: var(--ink-2); transform: translateY(-1px); }
.btn:active { transform: translateY(1px) scale(0.98); }
.btn[disabled] { opacity: 0.5; pointer-events: none; }
.btn-primary { --btn-bg: var(--brand); --btn-fg: #fff; --btn-bd: var(--brand); box-shadow: var(--shadow-brand); }
.btn-primary:hover { --btn-bg: var(--brand-600); border-color: var(--brand-600); }
.btn-accent { --btn-bg: var(--sun); --btn-fg: var(--ink); --btn-bd: var(--sun); box-shadow: 0 10px 24px -12px rgb(240 180 0 / 0.8); }
.btn-accent:hover { --btn-bg: #ffd54f; border-color: #ffd54f; }
.btn-dark { --btn-bg: var(--ink); --btn-fg: #fff; --btn-bd: var(--ink); }
.btn-ghost { --btn-bg: transparent; --btn-bd: transparent; }
.btn-ghost:hover { --btn-bg: var(--bg-2); border-color: transparent; }
.btn-soft { --btn-bg: var(--brand-50); --btn-fg: var(--brand-700); --btn-bd: transparent; }
.btn-soft:hover { --btn-bg: var(--brand-100); border-color: transparent; }
.btn-danger { --btn-bg: var(--coral); --btn-fg: #fff; --btn-bd: var(--coral); }
.btn-s { min-height: 36px; padding: 6px 14px; font-size: 14px; }
.btn-l { min-height: 56px; padding: 14px 28px; font-size: 16.5px; }
.btn-block { width: 100%; white-space: normal; text-align: center; }
.btn-icon { width: 44px; padding: 0; }
.btn-icon.btn-s { width: 36px; }

.link {
  color: var(--brand);
  font-weight: 650;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  background: linear-gradient(currentColor, currentColor) 0 100% / 0 2px no-repeat;
  transition: background-size 0.25s var(--ease);
}
.link:hover { background-size: 100% 2px; }

/* ---- Chips & badges ---------------------------------------------------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 6px 14px;
  border: 1.5px solid var(--line-2);
  border-radius: 999px;
  background: var(--surface);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-2);
  transition: all 0.18s var(--ease);
  white-space: nowrap;
}
.chip:hover { border-color: var(--brand); color: var(--brand-700); }
.chip[aria-pressed='true'], .chip.is-on {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  box-shadow: 0 8px 18px -10px rgb(43 89 255 / 0.8);
}
.chip[aria-pressed='true'] .chip-count { opacity: 0.8; }
.chip .ic { width: 16px; height: 16px; }
.chip-count { font-size: 12px; opacity: 0.55; font-variant-numeric: tabular-nums; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: var(--bg-2);
  color: var(--ink-2);
  white-space: nowrap;
}
.badge .ic { width: 13px; height: 13px; stroke-width: 2.2; }
.badge-state { background: var(--brand-50); color: var(--brand-700); }
.badge-foreign { background: var(--mint-50); color: var(--mint-700); }
.badge-private { background: var(--sun-50); color: var(--sun-700); }
.badge-ok { background: var(--mint-50); color: var(--mint-700); }
.badge-warn { background: var(--sun-50); color: var(--sun-700); }
.badge-bad { background: var(--coral-50); color: var(--coral-700); }
.badge-solid { background: var(--ink); color: #fff; }

.tag-est {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  color: var(--sun-700);
  border-bottom: 1.5px dotted currentColor;
  cursor: help;
}

/* Letter grade (A+ … C) — the platform's signature element */
.grade {
  --g: var(--mint);
  --gbg: var(--mint-50);
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 14px;
  background: var(--g);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 19px;
  letter-spacing: -0.04em;
  line-height: 1;
  box-shadow: inset 0 -3px 0 rgb(0 0 0 / 0.14);
}
.grade[data-g^='A'] { --g: var(--mint); }
.grade[data-g^='B'] { --g: var(--brand); }
.grade[data-g^='C'] { --g: #f0a020; }
.grade[data-g^='D'], .grade[data-g='—'] { --g: var(--line-2); color: var(--ink-2); }
.grade-s { width: 34px; height: 34px; font-size: 15px; border-radius: 11px; }
.grade-l { width: 64px; height: 64px; font-size: 28px; border-radius: 20px; }

/* Sticker label */
.sticker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--sun);
  color: var(--ink);
  font-weight: 750;
  font-size: 13px;
  box-shadow: 0 2px 0 rgb(0 0 0 / 0.12);
  transform: rotate(-3deg);
}

/* ---- Forms ------------------------------------------------------------- */
.label { display: block; font-size: 14px; font-weight: 650; color: var(--ink-2); margin-bottom: 6px; }
.hint { font-size: 13px; color: var(--muted); margin-top: 6px; }
.input, .select, .textarea {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border: 1.5px solid var(--line-2);
  border-radius: var(--r-s);
  background: var(--surface);
  font-size: 16px; /* ≥16px stops iOS zoom-on-focus */
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
}
.textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
.select {
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2339446a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--muted); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px rgb(43 89 255 / 0.15); }
.input-wrap { position: relative; }
.input-wrap > .ic { position: absolute; left: 15px; top: 50%; translate: 0 -50%; color: var(--muted); pointer-events: none; }
.input-wrap > .input { padding-left: 46px; }

/* Segmented control */
.seg {
  display: inline-flex;
  padding: 4px;
  gap: 2px;
  background: var(--bg-2);
  border-radius: 999px;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}
.seg::-webkit-scrollbar { display: none; }
.seg button {
  border: 0;
  background: transparent;
  min-height: 38px;
  padding: 6px 16px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 650;
  color: var(--ink-2);
  white-space: nowrap;
  transition: background 0.2s var(--ease), color 0.2s, box-shadow 0.2s;
}
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed='true'] { background: var(--surface); color: var(--brand-700); box-shadow: var(--shadow-1), 0 0 0 1px var(--line); }

/* Range slider */
.range { --p: 50%; appearance: none; width: 100%; height: 34px; background: transparent; cursor: pointer; }
.range::-webkit-slider-runnable-track { height: 10px; border-radius: 99px; background: linear-gradient(90deg, var(--brand) var(--p), var(--bg-3) var(--p)); }
.range::-moz-range-track { height: 10px; border-radius: 99px; background: var(--bg-3); }
.range::-moz-range-progress { height: 10px; border-radius: 99px; background: var(--brand); }
.range::-webkit-slider-thumb { appearance: none; width: 30px; height: 30px; margin-top: -10px; border-radius: 50%; background: var(--surface); border: 3px solid var(--brand); box-shadow: 0 4px 12px rgb(43 89 255 / 0.35); }
.range::-moz-range-thumb { width: 26px; height: 26px; border-radius: 50%; background: var(--surface); border: 3px solid var(--brand); box-shadow: 0 4px 12px rgb(43 89 255 / 0.35); }

/* Switch */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 550; }
.switch input { appearance: none; width: 46px; height: 28px; border-radius: 99px; background: var(--line-2); position: relative; transition: background 0.2s; flex: none; margin: 0; cursor: pointer; }
.switch input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-1); transition: transform 0.25s var(--spring); }
.switch input:checked { background: var(--mint); }
.switch input:checked::after { transform: translateX(18px); }

/* ---- Surfaces ---------------------------------------------------------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); box-shadow: var(--shadow-1); }
.panel-pad { padding: 20px; }
@media (min-width: 640px) { .panel-pad { padding: 28px; } }

.kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 8px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-2);
  box-shadow: var(--shadow-1);
}
.kicker::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--sun); box-shadow: 0 0 0 4px var(--sun-50); }

/* ---- University card --------------------------------------------------- */
.uni-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-l);
  overflow: hidden;
  isolation: isolate;
  transition: transform 0.3s var(--spring), box-shadow 0.3s var(--ease), border-color 0.2s;
}
.uni-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-2); border-color: var(--brand-100); }
.uni-card__media { position: relative; aspect-ratio: 16 / 10; background: var(--bg-2); overflow: hidden; }
.uni-card__media::after { content: ''; position: absolute; inset: 0; z-index: 1; background: linear-gradient(180deg, rgb(15 27 61 / 0.25), transparent 35%, transparent 60%, rgb(15 27 61 / 0.35)); pointer-events: none; }
.uni-card__badges { position: absolute; z-index: 2; left: 12px; top: 12px; display: flex; gap: 6px; flex-wrap: wrap; }
.uni-card__badges .badge { background: rgb(255 255 255 / 0.95); box-shadow: 0 2px 8px rgb(0 0 0 / 0.12); }
.uni-card__tools { position: absolute; right: 10px; top: 10px; display: flex; gap: 6px; z-index: 3; }
.uni-card__grade { position: absolute; z-index: 2; right: 12px; bottom: 12px; display: flex; align-items: center; gap: 6px; padding: 4px 10px 4px 4px; border-radius: 16px; background: rgb(255 255 255 / 0.95); box-shadow: 0 4px 14px rgb(0 0 0 / 0.18); font-size: 12px; font-weight: 750; color: var(--ink-2); }
.uni-card__grade .grade { width: 34px; height: 34px; font-size: 15px; border-radius: 12px; }
.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 0;
  background: rgb(255 255 255 / 0.95);
  color: var(--ink-2);
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.12);
  transition: background 0.15s, color 0.15s, transform 0.2s var(--spring);
}
.icon-btn:hover { color: var(--brand); transform: scale(1.08); }
.icon-btn:active { transform: scale(0.92); }
.icon-btn[aria-pressed='true'] { background: var(--brand); color: #fff; }
.icon-btn .ic { width: 18px; height: 18px; }
.uni-card__body { display: flex; flex-direction: column; gap: 10px; padding: 18px 18px 18px; flex: 1; }
.uni-card__city { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
.uni-card__city .ic { width: 15px; height: 15px; color: var(--brand); }
.uni-card__short { display: inline-block; font-family: var(--font-display); font-weight: 800; font-size: 13px; letter-spacing: 0.02em; color: var(--brand-700); background: var(--brand-50); padding: 2px 8px; border-radius: 6px; margin-right: 4px; vertical-align: 2px; }
.uni-card__title { font-family: var(--font-display); font-size: 20px; font-weight: 750; line-height: 1.18; letter-spacing: -0.025em; color: var(--ink); }
.uni-card__title a::after { content: ''; position: absolute; inset: 0; z-index: 1; }
.uni-card__title a:hover { color: var(--brand-700); }
.uni-card__facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: auto;
  padding-top: 4px;
}
.fact-mini { min-width: 0; padding: 10px 12px; border-radius: var(--r-s); background: var(--bg); }
.fact-mini dt { font-size: 11.5px; color: var(--muted); font-weight: 700; }
.fact-mini dd { margin: 2px 0 0; font-weight: 750; font-size: 14.5px; line-height: 1.3; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; color: var(--ink); }
.uni-card__fields { display: flex; gap: 6px; flex-wrap: wrap; }
.field-dot { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); padding: 4px 9px 4px 7px; border-radius: 999px; border: 1px solid var(--line); }
.field-dot .ic { width: 14px; height: 14px; color: var(--brand); }

/* Photo + designed fallback. The photo always paints ABOVE the cover. */
.cover {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  background-color: var(--cover-bg, var(--brand));
  background-image: var(--girih-light);
  background-size: 54px;
  color: #fff;
}
.cover[data-type='foreign'] { --cover-bg: #0f9d78; }
.cover[data-type='private'] { --cover-bg: #f08c00; }
.cover__arch { position: absolute; bottom: -2px; width: 46%; max-width: 220px; aspect-ratio: 3 / 3.4; border: 2px solid rgb(255 255 255 / 0.3); border-bottom: 0; border-radius: 50% 50% 0 0 / 38% 38% 0 0; }
.cover__mono { position: relative; font-family: var(--font-display); font-weight: 800; font-size: clamp(24px, 6vw, 40px); letter-spacing: -0.02em; padding-bottom: 6%; }
img[data-fallback] { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; object-fit: cover; transition: transform 0.6s var(--ease), opacity 0.4s; }
.uni-card:hover img[data-fallback] { transform: scale(1.05); }

/* ---- Chance meter, ring, gauge ---------------------------------------- */
.meter { display: grid; gap: 6px; }
.meter__row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 13.5px; font-weight: 600; }
.meter__row b { font-variant-numeric: tabular-nums; font-size: 15px; font-weight: 800; }
.meter__bar { height: 10px; border-radius: 99px; background: var(--bg-3); overflow: hidden; }
.meter__bar span { display: block; height: 100%; width: var(--v, 0%); border-radius: inherit; background: var(--c, var(--mint)); transition: width 0.8s var(--ease); animation: grow 0.9s var(--ease); }
@keyframes grow { from { width: 0; } }
.lvl-high { --c: var(--mint); color: var(--mint-700); }
.lvl-mid { --c: var(--sun); color: var(--sun-700); }
.lvl-low { --c: var(--coral); color: var(--coral-700); }

.ring { --v: 0; --c: var(--brand); --size: 64px; position: relative; width: var(--size); height: var(--size); flex: none; border-radius: 50%; background: conic-gradient(var(--c) calc(var(--v) * 1%), var(--bg-3) 0); display: grid; place-items: center; }
.ring::before { content: ''; position: absolute; inset: 6px; border-radius: 50%; background: var(--surface); }
.ring > span { position: relative; font-family: var(--font-display); font-weight: 800; font-size: calc(var(--size) * 0.28); font-variant-numeric: tabular-nums; letter-spacing: -0.03em; }
.ring > span small { font-size: 0.6em; font-weight: 700; opacity: 0.55; }

.gauge { position: relative; width: 210px; max-width: 100%; margin-inline: auto; }
.gauge svg { width: 100%; height: auto; overflow: visible; }
.gauge__track { fill: none; stroke: var(--bg-3); stroke-width: 16; stroke-linecap: round; }
.gauge__val { fill: none; stroke: var(--c, var(--mint)); stroke-width: 16; stroke-linecap: round; transition: stroke-dashoffset 0.9s var(--ease), stroke 0.3s; }
.gauge__num { position: absolute; left: 0; right: 0; bottom: 4px; text-align: center; }
.gauge__num b { display: block; font-family: var(--font-display); font-size: 42px; line-height: 1; font-weight: 800; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.gauge__num span { font-size: 13px; color: var(--muted); font-weight: 650; }

.stamp { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 800; color: var(--mint-700); background: var(--mint-50); border: 1.5px solid var(--mint); }

/* ---- Sheet / drawer ---------------------------------------------------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 90; background: rgb(13 29 99 / 0.35); backdrop-filter: blur(2px); opacity: 0; transition: opacity 0.25s var(--ease); }
.sheet { position: fixed; z-index: 91; left: 0; right: 0; bottom: 0; max-height: min(88dvh, 820px); display: flex; flex-direction: column; background: var(--bg); border-radius: var(--r-xl) var(--r-xl) 0 0; box-shadow: var(--shadow-3); transform: translateY(102%); transition: transform 0.36s var(--ease); padding-bottom: env(safe-area-inset-bottom); }
.sheet.is-open { transform: none; }
.sheet-backdrop.is-open { opacity: 1; }
.sheet__grab { width: 44px; height: 5px; border-radius: 9px; background: var(--line-2); margin: 10px auto 2px; flex: none; }
.sheet__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 20px 12px; border-bottom: 1px solid var(--line); flex: none; }
.sheet__head h2 { font-family: var(--font-display); font-size: 22px; font-weight: 750; letter-spacing: -0.02em; }
.sheet__body { overflow-y: auto; overscroll-behavior: contain; padding: 18px 20px 24px; flex: 1; -webkit-overflow-scrolling: touch; }
.sheet__foot { display: flex; gap: 10px; padding: 12px 20px; border-top: 1px solid var(--line); background: var(--surface); flex: none; }
@media (min-width: 900px) {
  .sheet { left: auto; top: 0; width: 440px; max-height: none; border-radius: var(--r-xl) 0 0 var(--r-xl); transform: translateX(102%); }
  .sheet__grab { display: none; }
  .sheet__head { padding-top: 22px; }
}
html.is-locked, html.is-locked body { overflow: hidden; }

/* ---- Toast ------------------------------------------------------------- */
.toasts { position: fixed; z-index: 120; left: 50%; bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom)); translate: -50% 0; display: grid; gap: 8px; width: min(420px, calc(100vw - 32px)); pointer-events: none; }
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: var(--r); background: var(--ink); color: #fff; font-size: 14.5px; font-weight: 550; box-shadow: var(--shadow-3); animation: toast-in 0.35s var(--spring); pointer-events: auto; }
.toast .ic { color: var(--sun); }
.toast a { color: var(--sun); font-weight: 750; margin-left: auto; white-space: nowrap; }
.toast.is-leaving { animation: toast-out 0.25s var(--ease) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(0.96); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }

/* ---- Misc -------------------------------------------------------------- */
.empty { display: grid; justify-items: center; text-align: center; gap: 12px; padding: 48px 20px; border: 2px dashed var(--line-2); border-radius: var(--r-l); background: var(--surface); }
.empty__icon { width: 68px; height: 68px; border-radius: 22px; display: grid; place-items: center; background: var(--brand-50); color: var(--brand); }
.empty h3 { font-family: var(--font-display); font-size: 22px; font-weight: 750; }
.empty p { color: var(--muted); max-width: 42ch; margin: 0; }

.skeleton { background: linear-gradient(90deg, var(--bg-2) 0%, var(--bg-3) 50%, var(--bg-2) 100%); background-size: 200% 100%; animation: sk 1.3s linear infinite; border-radius: var(--r-s); }
@keyframes sk { to { background-position: -200% 0; } }

.hscroll { display: flex; gap: 14px; overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x mandatory; scroll-padding-inline: var(--gutter); padding: 4px var(--gutter) 8px; margin-inline: calc(var(--gutter) * -1); scrollbar-width: none; }
.hscroll::-webkit-scrollbar { display: none; }
.hscroll > * { scroll-snap-align: start; flex: none; }

.note { display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--r); background: var(--sun-50); color: var(--sun-700); font-size: 14px; line-height: 1.5; font-weight: 500; }
.note .ic { margin-top: 1px; flex: none; }
.note-info { background: var(--brand-50); color: var(--brand-700); }
.note p { margin: 0; }

.checklist { display: grid; gap: 10px; }
.checklist li { display: flex; gap: 10px; align-items: flex-start; }
.checklist .ic { color: var(--mint); margin-top: 2px; flex: none; }

.divider-label { display: flex; align-items: center; gap: 12px; font-size: 12px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.divider-label::after { content: ''; height: 1px; flex: 1; background: var(--line); }

/* Count-up numbers & list enter animation */
.pop-in { animation: pop-in 0.45s var(--spring) both; }
@keyframes pop-in { from { opacity: 0; transform: translateY(16px) scale(0.95); } }
@media (prefers-reduced-motion: reduce) { .pop-in { animation: none; } }
.uni-card__mine { position: absolute; z-index: 2; left: 12px; bottom: 14px; box-shadow: 0 4px 14px rgb(0 0 0 / 0.18); background: rgb(255 255 255 / 0.96) !important; }
.uni-card__mine .ic { width: 13px; height: 13px; }
