/* =============================================================
   NetDrill — Design System
   ============================================================= */
:root {
  /* --- Color: neutrals (cool slate) --- */
  --bg:            #eef1f5;
  --surface:       #ffffff;
  --surface-soft:  #f7f9fb;
  --ink:           #1b2430;
  --ink-2:         #4a5667;
  --ink-3:         #7b8794;
  --line:          #e4e8ee;
  --line-2:        #d3d9e1;

  /* --- Color: brand --- */
  --shell:         #131a26;   /* header / sidebar */
  --shell-soft:    #1d2735;
  --accent:        #4f6ef2;   /* indigo */
  --accent-strong: #3a55d9;
  --accent-soft:   #eef1fe;
  --accent-ink:    #2f43a8;

  /* --- Color: semantic (muted) --- */
  --ok:            #1f9254;
  --ok-soft:       #ecf6f0;
  --ok-line:       #bfe3cd;
  --bad:           #cf3f57;
  --bad-soft:      #fceef1;
  --bad-line:      #f2ccd5;

  /* --- Typography --- */
  --font-sans: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system,
    "Hiragino Kaku Gothic ProN", "Yu Gothic UI", Meiryo, sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "SF Mono", "Consolas",
    "Liberation Mono", monospace;

  /* --- Radius --- */
  --r-sm: 7px;
  --r-md: 11px;
  --r-lg: 16px;

  /* --- Shadow --- */
  --sh-1: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --sh-2: 0 6px 16px -4px rgba(16, 24, 40, .10), 0 2px 6px -2px rgba(16, 24, 40, .06);
  --sh-focus: 0 0 0 3px rgba(79, 110, 242, .18);
}

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

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

body {
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.65;
  font-size: 17.5px;
  letter-spacing: .01em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

code, kbd, .mono { font-family: var(--font-mono); }

/* =============================================================
   Header
   ============================================================= */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  padding: 0 28px;
  background: var(--shell);
  border-bottom: 1px solid rgba(255, 255, 255, .06);
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  font-weight: 600;
  font-size: 1.22rem;
  letter-spacing: -.01em;
  transition: opacity .15s ease;
}
.logo:hover { opacity: .9; }
.logo:focus-visible { outline: none; box-shadow: var(--sh-focus); border-radius: var(--r-sm); }

.logo-mark {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(140deg, var(--accent) 0%, #6d83f6 100%);
  color: #fff;
  font-size: 1rem;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12);
}
.logo-text { color: #fff; }
.logo-net  { color: #aeb8c9; font-weight: 500; }
.logo-drill { color: #fff; font-weight: 700; }

/* =============================================================
   Layout
   ============================================================= */
.layout {
  display: flex;
  align-items: flex-start;
  min-height: calc(100vh - 60px);
  max-width: 1320px;
  margin: 0 auto;
}

.sidebar {
  width: 232px;
  flex-shrink: 0;
  align-self: stretch;
  padding: 26px 16px;
}

.tab-list { list-style: none; display: flex; flex-direction: column; gap: 3px; }

.tab {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 14px;
  border-radius: var(--r-sm);
  color: var(--ink-2);
  cursor: pointer;
  font-size: .95rem;
  font-weight: 500;
  transition: background .15s ease, color .15s ease;
}
.tab:hover { background: #e6eaf1; color: var(--ink); }
.tab.active {
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 600;
}
.tab.active .tab-label { color: var(--accent-ink); }

.tab-label { font-size: .95rem; }
.tab-icon { font-size: 1.05rem; }
.tab-num { font-size: 1rem; font-weight: 700; color: var(--ink-3); }
.tab.active .tab-num { color: var(--accent); }

/* =============================================================
   Content surface
   ============================================================= */
.content {
  flex: 1;
  min-width: 0;
  background: var(--surface);
  margin: 22px 22px 22px 6px;
  padding: 34px 38px 38px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
}

.exercise { margin-bottom: 22px; }

.question-text {
  font-size: 1.18rem;
  font-weight: 600;
  letter-spacing: -.01em;
  color: var(--ink);
  margin-bottom: 18px;
}

.question-sub {
  font-size: .96rem;
  color: var(--ink-2);
  margin-bottom: 20px;
}
.question-sub code {
  font-size: .9em;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  padding: 1px 6px;
  border-radius: 5px;
  color: var(--accent-ink);
}

.dest-highlight {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent-soft);
  border: 1px solid #d7defb;
  border-radius: var(--r-sm);
  padding: 9px 15px;
  font-family: var(--font-mono);
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--accent-ink);
  margin-bottom: 22px;
}

/* =============================================================
   Routing table
   ============================================================= */
table.routing {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-bottom: 24px;
  font-family: var(--font-mono);
  font-size: .9rem;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
}

table.routing th,
table.routing td {
  padding: 11px 16px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}
table.routing tbody tr:last-child td { border-bottom: none; }

table.routing th {
  background: var(--surface-soft);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: .82rem;
  letter-spacing: .02em;
  color: var(--ink-2);
}
table.routing td { color: var(--ink); }

table.routing th[title] {
  cursor: help;
  text-decoration: underline dotted var(--line-2);
  text-underline-offset: 3px;
}

table.routing tr.row-matched td { background: var(--ok-soft); }
table.routing tr.row-winner td {
  background: #e1f0e8;
  color: #115c34;
  font-weight: 700;
}
table.routing tr.row-nomatch td { color: var(--ink-3); }

/* =============================================================
   Options (radio choices)
   ============================================================= */
.options { display: flex; flex-direction: column; gap: 9px; margin-bottom: 10px; }

.option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: .96rem;
  color: var(--ink);
  background: var(--surface);
  transition: border-color .14s ease, background .14s ease, box-shadow .14s ease;
}
.option:hover { border-color: var(--accent); background: var(--accent-soft); }
.option input { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; }

.option.opt-correct {
  border-color: var(--ok);
  background: var(--ok-soft);
  color: #115c34;
  font-weight: 600;
}
.option.opt-wrong {
  border-color: var(--bad);
  background: var(--bad-soft);
  color: #92283a;
}

/* =============================================================
   Inputs
   ============================================================= */
.subnet-inputs { display: flex; flex-direction: column; gap: 16px; margin-bottom: 14px; max-width: 460px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: .9rem; font-weight: 600; color: var(--ink-2); }

.field input {
  padding: 11px 14px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: 1rem;
  color: var(--ink);
  background: var(--surface);
  transition: border-color .14s ease, box-shadow .14s ease;
}
.field input::placeholder { color: var(--ink-3); }
.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--sh-focus);
}

/* =============================================================
   Buttons
   ============================================================= */
.btn {
  display: inline-block;
  width: 100%;
  padding: 13px 18px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  font-family: var(--font-sans);
  font-size: .98rem;
  font-weight: 600;
  letter-spacing: .01em;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease, transform .04s ease;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:focus-visible { outline: none; box-shadow: var(--sh-focus); }

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 2px rgba(58, 85, 217, .25);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-strong); }

.btn-secondary {
  background: var(--surface);
  color: var(--ink-2);
  border-color: var(--line-2);
  margin-top: 18px;
}
.btn-secondary:hover:not(:disabled) { background: var(--surface-soft); border-color: var(--ink-3); color: var(--ink); }

/* =============================================================
   Result + explanation
   ============================================================= */
.result { margin-top: 22px; }
.result.hidden, .btn.hidden { display: none; }

.verdict {
  display: flex;
  align-items: center;
  gap: 11px;
  font-size: 1.04rem;
  font-weight: 700;
  padding: 14px 18px;
  border-radius: var(--r-md);
  margin-bottom: 16px;
  border: 1px solid transparent;
}
.verdict.correct { background: var(--ok-soft); color: #136c3e; border-color: var(--ok-line); }
.verdict.wrong   { background: var(--bad-soft); color: #a52b41; border-color: var(--bad-line); }

.verdict-icon {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: .9rem;
  color: #fff;
  flex-shrink: 0;
}
.verdict.correct .verdict-icon { background: var(--ok); }
.verdict.wrong .verdict-icon { background: var(--bad); }

.verdict-msg { font-size: .9rem; font-weight: 500; opacity: .85; margin-left: 2px; }

.explanation {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 20px 22px;
  font-size: .94rem;
  color: var(--ink);
}
.explanation h4 {
  margin: 0 0 9px;
  font-size: .82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-3);
}
.explanation h4 + p, .explanation p + p { margin-top: 0; }
.explanation p { margin-bottom: 10px; line-height: 1.7; }
.explanation p:last-child { margin-bottom: 0; }
.explanation > ul + h4 { margin-top: 16px; }
.explanation code {
  font-family: var(--font-mono);
  background: #eef1f6;
  border: 1px solid var(--line);
  padding: 1px 6px;
  border-radius: 5px;
  font-size: .88em;
  color: var(--accent-ink);
}
.explanation ul { margin: 6px 0 0; padding-left: 20px; }
.explanation li { margin-bottom: 5px; }

.match-yes { color: var(--ok); font-weight: 600; }
.match-no { color: var(--ink-3); }
.match-winner { color: #136c3e; font-weight: 700; }

/* =============================================================
   Home
   ============================================================= */
.home-hero {
  padding: 26px 0 30px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 30px;
}
.home-title {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--ink);
  margin-bottom: 8px;
}
.home-subtitle { font-size: 1.02rem; color: var(--ink-2); }

.home-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(258px, 1fr));
  gap: 18px;
}

.home-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 22px 22px 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--sh-1);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.home-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--sh-2);
  border-color: #c9d2f6;
}
.home-card-num {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 1rem;
  font-weight: 700;
}
.home-card-title { font-size: 1.08rem; font-weight: 700; letter-spacing: -.01em; color: var(--ink); }
.home-card-desc { font-size: .9rem; line-height: 1.65; color: var(--ink-2); flex: 1; }

.btn-start {
  margin-top: 6px;
  padding: 10px 14px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--accent-ink);
  font-family: var(--font-sans);
  font-size: .92rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.home-card:hover .btn-start { background: var(--accent); border-color: var(--accent); color: #fff; }

/* =============================================================
   Topology (horizontal)
   ============================================================= */
.topo-h {
  display: flex;
  align-items: center;
  overflow-x: auto;
  background:
    radial-gradient(circle at 1px 1px, #dfe5ee 1px, transparent 0) 0 0 / 22px 22px,
    var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 30px 26px;
  min-height: 190px;
  margin-bottom: 22px;
}

.th-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 84px;
  padding: 12px 8px 10px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  flex-shrink: 0;
  background: var(--surface);
  box-shadow: var(--sh-1);
  text-align: center;
}
.th-pc     { box-shadow: inset 0 2px 0 #6aa3e8, var(--sh-1); }
.th-router { box-shadow: inset 0 2px 0 #e8a13c, var(--sh-1); }
.th-server { box-shadow: inset 0 2px 0 #4fa777, var(--sh-1); }

.th-icon { font-size: 1.7rem; line-height: 1; }
.th-name {
  font-size: .76rem;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--ink);
  margin-top: 6px;
}

/* wire spans full node height; line sits at vertical middle */
.th-wire { position: relative; align-self: stretch; flex: 1; min-width: 124px; }

.th-wire-line {
  position: absolute;
  top: 50%; left: 0; right: 0;
  transform: translateY(-50%);
  height: 2px;
  background: linear-gradient(90deg, #aab4c2, #c2cad6);
  border-radius: 2px;
}

.th-wire-label {
  position: absolute;
  bottom: 50%; left: 50%;
  transform: translateX(-50%);
  margin-bottom: 44px;
  font-family: var(--font-mono);
  font-size: .72rem;
  font-weight: 600;
  color: var(--ink-2);
  white-space: nowrap;
  background: var(--surface);
  border: 1px solid var(--line-2);
  padding: 2px 8px;
  border-radius: 999px;
}

.th-wire-ifs {
  position: absolute;
  bottom: 50%; left: 0; right: 0;
  margin-bottom: 7px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 12px;
}

.th-if-tag {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.25;
  white-space: nowrap;
  font-family: var(--font-mono);
}
.th-if-left { align-items: center; }
.th-if-right { align-items: center; margin-left: auto; }
.th-if-tag .th-if-name { font-size: .74rem; color: var(--ink-3); }
.th-if-tag .th-if-ip { font-size: .86rem; font-weight: 700; color: var(--accent-ink); }

/* =============================================================
   Responsive
   ============================================================= */
/* =============================================================
   Footer
   ============================================================= */
.site-footer {
  background: var(--shell);
  color: #aeb8c9;
  border-top: 1px solid rgba(255, 255, 255, .06);
}
.footer-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 26px 28px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 26px;
}
.footer-brand { font-weight: 600; color: #fff; font-size: 1rem; }
.footer-mark { color: var(--accent); }
.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
  flex: 1;
}
.footer-links a {
  color: #aeb8c9;
  text-decoration: none;
  font-size: .9rem;
  transition: color .15s ease;
}
.footer-links a:hover { color: #fff; }
.footer-copy { color: #6d7888; font-size: .85rem; }

/* =============================================================
   Document pages (privacy etc.)
   ============================================================= */
.doc {
  max-width: 820px;
  margin: 0 auto;
  padding: 8px 22px 56px;
}
.doc-body {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  padding: 40px 44px 46px;
  margin-top: 26px;
}
.doc-body h1 {
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--ink);
  margin-bottom: 6px;
}
.doc-updated { color: var(--ink-3); font-size: .9rem; margin-bottom: 26px; }
.doc-body h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink);
  margin: 28px 0 10px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.doc-body h2:first-of-type { border-top: none; padding-top: 0; }
.doc-body p { color: var(--ink-2); margin-bottom: 12px; line-height: 1.85; }
.doc-body ul { color: var(--ink-2); margin: 4px 0 12px; padding-left: 22px; line-height: 1.85; }
.doc-body li { margin-bottom: 4px; }
.doc-body a { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 2px; }
.doc-body a:hover { color: var(--accent-strong); }
.doc-back { margin-top: 30px; padding-top: 20px; border-top: 1px solid var(--line); }
.doc-back a { font-weight: 600; }

@media (max-width: 860px) {
  .app-header { padding: 0 18px; }
  .layout { flex-direction: column; }
  .sidebar { width: 100%; align-self: auto; padding: 12px 14px; }
  .tab-list { flex-direction: row; flex-wrap: wrap; gap: 6px; }
  .tab { flex: 1 1 auto; justify-content: center; padding: 10px 12px; }

  .content {
    margin: 0 14px 16px;
    padding: 22px 18px 26px;
    border-radius: var(--r-md);
  }

  .question-text { font-size: 1.08rem; }

  table.routing { display: block; overflow-x: auto; white-space: nowrap; }

  .btn { min-height: 46px; }
  .home-cards { grid-template-columns: 1fr; }
  .home-title { font-size: 1.6rem; }
}
