/* Design tokens */
:root {
  --bg:           #0f0f0f;
  --surface:      #1a1a1a;
  --surface-2:    #222;
  --border:       #333;
  --text:         #e0e0e0;
  --muted:        #888;
  --accent:       #3a7a3a;
  --accent-h:     #4a9a4a;
  --err:          #c44444;
  --ok:           #44c444;
  --radius:       6px;
  --font:         'Courier New', Courier, monospace;
}

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

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

/* Skip link */
.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
.skip-link:focus {
  left: 1rem;
  top: 1rem;
  width: auto;
  height: auto;
  background: var(--accent);
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  z-index: 100;
}

/* Header */
header {
  border-bottom: 1px solid var(--border);
  padding: 1rem 2rem;
}
header h1 {
  color: #fff;
  font-size: 1.1rem;
  font-weight: normal;
  letter-spacing: 0.05em;
}

/* WASM status */
#wasm-status {
  border-radius: var(--radius);
  font-size: 0.8rem;
  margin: 1rem 2rem;
  padding: 0.4rem 0.9rem;
}
#wasm-status[data-state="loading"] { background: var(--surface);   color: var(--muted); }
#wasm-status[data-state="ready"]   { background: #142614;          color: var(--ok);    }
#wasm-status[data-state="failed"]  { background: #2a1414;          color: var(--err);   }

/* Layout */
main {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 2rem 3rem;
}

/* Tabs */
[role="tablist"] {
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem;
  margin-bottom: 1.5rem;
}

[role="tab"] {
  background: none;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.85rem;
  padding: 0.45rem 1rem;
  transition: color 0.12s;
}
[role="tab"]:hover                  { color: var(--text); }
[role="tab"]:focus-visible          { outline: 2px solid var(--accent); outline-offset: -2px; }
[role="tab"][aria-selected="true"]  {
  background: var(--surface);
  border-color: var(--border);
  border-bottom-color: var(--surface);
  color: #fff;
  margin-bottom: -1px;
}

[role="tabpanel"] { outline: none; }
[role="tabpanel"][hidden] { display: none; }

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1rem;
  padding: 1.1rem 1.25rem;
}
.card-title {
  color: #ccc;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  margin-bottom: 1rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

/* Form fields */
.field       { margin-bottom: 0.7rem; }
.row         { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.row .field  { flex: 1; min-width: 110px; }

label {
  color: var(--muted);
  display: block;
  font-size: 0.78rem;
  margin-bottom: 0.2rem;
}

input[type="text"],
input[type="number"],
select {
  appearance: none;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.88rem;
  padding: 0.35rem 0.6rem;
  width: 100%;
}
input:focus,
select:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 2px rgba(58,122,58,0.3);
}

/* Action button */
button.action {
  background: var(--accent);
  border: none;
  border-radius: 3px;
  color: #fff;
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.85rem;
  margin-top: 0.3rem;
  padding: 0.4rem 1.1rem;
  transition: background 0.12s;
}
button.action:hover                { background: var(--accent-h); }
button.action:focus-visible        { outline: 2px solid var(--accent-h); outline-offset: 2px; }
button.action[disabled]            { background: #2a2a2a; color: #555; cursor: not-allowed; }

/* Result area */
.result {
  background: #0a0a0a;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.82rem;
  margin-top: 0.75rem;
  min-height: 2rem;
  padding: 0.65rem 0.75rem;
}

/* Result table rows */
.r-row {
  align-items: baseline;
  display: flex;
  gap: 0.5rem;
  padding: 0.1rem 0;
}
.r-key {
  color: var(--muted);
  flex-shrink: 0;
  font-size: 0.78rem;
  min-width: 160px;
}
.r-val { color: var(--text); word-break: break-all; }

.err-text { color: var(--err); }
.ok-text  { color: var(--ok);  }

/* Warning levels */
.lvl-info    { color: #99aadd; }
.lvl-caution { color: #ddbb55; }
.lvl-danger  { color: var(--err); }

/* Resistor body diagram */
.r-diagram {
  align-items: center;
  display: flex;
  justify-content: center;
  margin: 0.75rem 0 0.25rem;
}
.r-lead {
  background: #777;
  height: 3px;
  width: 28px;
}
.r-body {
  background: #c8a96e;
  border-radius: 5px;
  display: flex;
  height: 22px;
  min-width: 56px;
  overflow: hidden;
}
.r-band {
  flex: 1;
  min-width: 7px;
}

/* Band color swatches in result */
.band-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.3rem;
}
.band-chip {
  border: 1px solid #555;
  border-radius: 3px;
  display: inline-flex;
  font-size: 0.72rem;
  gap: 0.3rem;
  align-items: center;
  padding: 0.15rem 0.45rem;
}
.band-dot {
  border-radius: 50%;
  display: inline-block;
  height: 10px;
  width: 10px;
}

/* Footer CTA */
footer {
  border-top: 1px solid var(--border);
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  padding: 1.25rem 2rem 2rem;
}

.cta-link {
  align-items: center;
  color: var(--muted);
  display: inline-flex;
  font-size: 0.8rem;
  gap: 0.4rem;
  letter-spacing: 0.03em;
  text-decoration: none;
  transition: color 0.12s;
}
.cta-link:hover       { color: var(--accent-h); }
.cta-link:focus-visible {
  color: var(--accent-h);
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}
.cta-link svg { flex-shrink: 0; }

.app-version {
  color: var(--muted);
  font-size: 0.75rem;
  opacity: 0.55;
  align-self: center;
}

@media (max-width: 600px) {
  header, main { padding-left: 1rem; padding-right: 1rem; }
  #wasm-status { margin-left: 1rem; margin-right: 1rem; }
  .r-key { min-width: 110px; }
}
