:root {
  color-scheme: light;
  --ink: #1f2933;
  --muted: #667085;
  --line: #d8dee8;
  --paper: #f6f7f9;
  --panel: #ffffff;
  --green: #2c7a5b;
  --amber: #b77818;
  --red: #b64f4f;
  --shadow: 0 18px 50px rgba(31, 41, 51, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(31, 41, 51, 0.04) 1px, transparent 1px),
    linear-gradient(rgba(31, 41, 51, 0.04) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
  font-family: Arial, Helvetica, sans-serif;
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(1180px, calc(100vw - 48px));
  margin: 0 auto;
  padding: 20px 0;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--green);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.8rem, 3.4vw, 3rem);
}

h2 {
  margin-bottom: 8px;
  font-size: 1.08rem;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(360px, 1.1fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.visual-panel {
  display: grid;
  place-items: center;
  min-height: 360px;
  padding: 26px;
  border-right: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(44, 122, 91, 0.08), transparent 42%),
    #fbfcfd;
}

.resistor-wrap {
  display: grid;
  grid-template-columns: 1fr minmax(230px, 380px) 1fr;
  align-items: center;
  width: 100%;
}

.lead {
  height: 10px;
  background: linear-gradient(#c8cdd4, #929aa5);
}

.resistor-body {
  position: relative;
  display: flex;
  justify-content: center;
  gap: clamp(14px, 4vw, 28px);
  min-height: 110px;
  padding: 0 34px;
  border: 2px solid #b9a273;
  border-radius: 8px;
  background:
    radial-gradient(circle at 24% 30%, rgba(255, 255, 255, 0.42), transparent 24%),
    linear-gradient(90deg, #ccb177, #efd99f 18%, #dbc083 50%, #efd99f 82%, #ccb177);
  box-shadow: inset 0 -16px 30px rgba(86, 65, 30, 0.18);
}

.stripe {
  width: 18px;
  min-height: 110px;
  border-right: 1px solid rgba(31, 41, 51, 0.2);
  border-left: 1px solid rgba(255, 255, 255, 0.28);
}

.calc-panel {
  display: grid;
  gap: 16px;
  padding: 22px;
}

label {
  display: grid;
  gap: 6px;
}

label span,
output span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 11px;
  color: var(--ink);
  background: #fff;
  font-size: 1.05rem;
  text-transform: uppercase;
}

.hint,
.message,
.reference-panel p {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.hint {
  margin-bottom: 0;
}

.touch-panel {
  display: grid;
  gap: 10px;
}

.touch-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

button {
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  cursor: pointer;
  touch-action: manipulation;
}

button:active {
  transform: translateY(1px);
}

.utility-button {
  min-height: 42px;
  padding: 8px 13px;
  font-size: 0.9rem;
  font-weight: 700;
}

.color-pad {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.color-button {
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  gap: 8px;
  min-height: 62px;
  padding: 8px;
  text-align: left;
}

.color-button strong,
.color-button span {
  display: block;
}

.color-button strong {
  font-size: 1.08rem;
  line-height: 1;
}

.color-button span {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.color-button .swatch {
  width: 28px;
  height: 28px;
}

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

output,
.parsed-panel,
.reference-panel article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

output {
  display: grid;
  gap: 6px;
  min-height: 84px;
  padding: 13px;
}

output strong {
  font-size: clamp(1.05rem, 2vw, 1.55rem);
  line-height: 1.15;
}

.parsed-panel {
  padding: 14px;
}

.band-list,
.code-grid {
  display: grid;
  gap: 8px;
}

.band-list {
  grid-template-columns: repeat(auto-fit, minmax(125px, 1fr));
}

.band-chip,
.code-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 8px;
  background: #fbfcfd;
  font-size: 0.88rem;
}

.swatch {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  border: 1px solid rgba(31, 41, 51, 0.2);
  border-radius: 50%;
}

.message {
  min-height: 20px;
  margin: 12px 0 0;
}

.message.error {
  color: var(--red);
  font-weight: 700;
}

.reference-panel {
  display: grid;
  grid-template-columns: 0.8fr 1.2fr;
  gap: 14px;
  margin-top: 14px;
}

.reference-panel article {
  padding: 15px;
}

.code-grid {
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 24px, 1180px);
  }

  .workspace,
  .reference-panel,
  .result-grid {
    grid-template-columns: 1fr;
  }

  .color-pad {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .visual-panel {
    min-height: 260px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .resistor-wrap {
    grid-template-columns: minmax(28px, 1fr) minmax(210px, 320px) minmax(28px, 1fr);
  }
}

@media (max-width: 430px) {
  .color-pad {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
