:root {
  --ink: #171512;
  --ink-soft: #6d665c;
  --paper: #f1eee7;
  --paper-deep: #e6e0d5;
  --night: #11100e;
  --line: rgba(23, 21, 18, 0.16);
  --warm: #f2b36d;
  --danger: #9d3f32;
  --success: #2f6851;
  --display: "Fraunces", Georgia, serif;
  --body: "IBM Plex Sans JP", sans-serif;
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.65;
}
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
[hidden] { display: none !important; }

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 20;
  opacity: .07;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
}

.site-header, .site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1440px, calc(100% - 80px));
  margin: 0 auto;
}
.site-header { height: 92px; border-bottom: 1px solid var(--line); }
.site-footer { min-height: 76px; border-top: 1px solid var(--line); color: var(--ink-soft); font-size: 10px; letter-spacing: .16em; }
.site-footer a, .back-link { color: inherit; text-decoration: none; border-bottom: 1px solid currentColor; }
.wordmark { color: inherit; text-decoration: none; font-family: var(--display); font-size: 21px; font-weight: 650; letter-spacing: .08em; }
.wordmark span { display: inline-block; margin-left: 12px; font-family: var(--body); font-size: 8px; font-weight: 600; letter-spacing: .2em; color: var(--ink-soft); }
.status-chip { display: flex; gap: 9px; align-items: center; font-size: 11px; letter-spacing: .08em; }
.status-chip > span:first-child { width: 8px; height: 8px; border-radius: 50%; background: #aaa49b; box-shadow: 0 0 0 4px rgba(100, 96, 89, .08); }
.status-chip[data-state="online"] > span:first-child { background: #37785e; box-shadow: 0 0 0 4px rgba(55, 120, 94, .12); }
.status-chip[data-state="paused"] > span:first-child { background: #bc812f; box-shadow: 0 0 0 4px rgba(188, 129, 47, .12); }
.status-chip[data-state="offline"] > span:first-child { background: #9d3f32; }

.control-shell {
  display: grid;
  grid-template-columns: minmax(250px, .8fr) minmax(360px, 1.15fr) minmax(330px, .9fr);
  width: min(1440px, calc(100% - 80px));
  min-height: calc(100vh - 168px);
  margin: 0 auto;
}
.intro { padding: clamp(70px, 9vw, 132px) 30px 70px 0; align-self: start; }
.eyebrow { margin: 0 0 36px; color: var(--ink-soft); font-size: 10px; font-weight: 600; letter-spacing: .24em; }
.intro h1, .admin-shell h1 { margin: 0; font-family: var(--display); font-size: clamp(44px, 4.2vw, 72px); font-weight: 500; line-height: 1.12; letter-spacing: -.045em; }
.intro h1 em { color: #a75236; font-style: normal; }
.intro-copy { max-width: 270px; margin: 35px 0 0; color: var(--ink-soft); font-size: 13px; }

.lamp-stage {
  position: relative;
  min-height: 630px;
  overflow: hidden;
  background: var(--night);
  border-inline: 1px solid rgba(255,255,255,.04);
}
.lamp-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 33%, rgba(255,255,255,.05), transparent 47%), linear-gradient(115deg, transparent 54%, rgba(255,255,255,.025) 54.2%, transparent 54.5%);
}
.halo {
  --lamp-color: #f2b36d;
  --lamp-strength: .8;
  position: absolute;
  width: min(32vw, 450px);
  aspect-ratio: 1;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--lamp-color);
  box-shadow:
    0 0 40px color-mix(in srgb, var(--lamp-color) 90%, transparent),
    0 0 120px color-mix(in srgb, var(--lamp-color) calc(var(--lamp-strength) * 70%), transparent),
    0 0 230px color-mix(in srgb, var(--lamp-color) 35%, transparent);
  transition: background .35s ease, box-shadow .35s ease, filter .35s ease, opacity .35s ease;
}
.halo::after { content: ""; position: absolute; inset: 4%; border-radius: inherit; border: 1px solid rgba(255,255,255,.34); }
.halo-core { position: absolute; inset: 28%; border-radius: 50%; background: rgba(255,255,255,.55); filter: blur(20px); }
.halo.is-off { opacity: .13; filter: grayscale(1); box-shadow: none; }
.lamp-caption { position: absolute; left: 36px; right: 36px; bottom: 30px; display: flex; justify-content: space-between; align-items: end; color: rgba(255,255,255,.68); }
.lamp-caption span { font-size: 9px; letter-spacing: .2em; }
.lamp-caption strong { color: #fff; font-size: 12px; letter-spacing: .1em; }

.control-panel { position: relative; align-self: center; padding: 60px clamp(26px, 4vw, 64px); }
.control-row { display: flex; justify-content: space-between; align-items: center; }
.power-row { padding-bottom: 30px; border-bottom: 1px solid var(--line); }
.power-row strong { display: block; margin-top: 3px; font-size: 16px; }
.control-label { display: block; color: var(--ink-soft); font-size: 9px; letter-spacing: .2em; }
.power-switch { position: relative; display: block; width: 62px; height: 34px; cursor: pointer; }
.power-switch input { position: absolute; opacity: 0; }
.power-switch > span:not(.sr-only) { display: block; width: 100%; height: 100%; border-radius: 99px; background: #cbc4b9; transition: .25s ease; }
.power-switch > span:not(.sr-only)::after { content: ""; position: absolute; width: 26px; height: 26px; left: 4px; top: 4px; border-radius: 50%; background: #fff; box-shadow: 0 2px 7px rgba(0,0,0,.18); transition: transform .25s ease; }
.power-switch input:checked + span { background: var(--ink); }
.power-switch input:checked + span::after { transform: translateX(28px); background: var(--warm); }
.power-switch input:focus-visible + span { outline: 3px solid rgba(157,63,50,.25); outline-offset: 3px; }

.control-block { padding: 31px 0; border-bottom: 1px solid var(--line); }
.control-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; }
.control-heading label { font-weight: 600; }
.control-heading output { font-family: var(--display); font-size: 25px; }
.control-heading > span { color: var(--ink-soft); font-size: 9px; letter-spacing: .2em; }
.range { width: 100%; height: 24px; margin: 0; appearance: none; background: transparent; cursor: pointer; }
.range::-webkit-slider-runnable-track { height: 3px; background: linear-gradient(to right, var(--ink), #d3ccc1); }
.range::-moz-range-track { height: 3px; background: #d3ccc1; }
.range::-webkit-slider-thumb { width: 17px; height: 17px; margin-top: -7px; appearance: none; border: 4px solid var(--paper); border-radius: 50%; background: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.range::-moz-range-thumb { width: 12px; height: 12px; border: 4px solid var(--paper); border-radius: 50%; background: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.range:focus-visible { outline: 2px solid #a75236; outline-offset: 5px; }
.range-ticks { display: flex; justify-content: space-between; color: var(--ink-soft); font-size: 8px; letter-spacing: .15em; }
.color-line { display: flex; align-items: center; gap: 22px; }
.color-picker { position: relative; flex: 0 0 auto; width: 52px; height: 52px; cursor: pointer; }
.color-picker input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.color-picker span { --selected: #f2b36d; display: block; width: 100%; height: 100%; border: 8px solid var(--paper); border-radius: 50%; background: var(--selected); box-shadow: 0 0 0 1px var(--ink); }
.color-picker:focus-within span { outline: 3px solid rgba(157,63,50,.25); outline-offset: 3px; }
.presets { display: flex; gap: clamp(7px, 1vw, 12px); }
.presets button { width: 29px; height: 29px; padding: 0; border: 1px solid rgba(0,0,0,.16); border-radius: 50%; background: var(--preset); cursor: pointer; transition: transform .2s ease; }
.presets button:hover, .presets button:focus-visible { transform: translateY(-3px); outline: 2px solid var(--ink); outline-offset: 3px; }

.apply-button { display: flex; justify-content: space-between; align-items: center; width: 100%; min-height: 59px; margin-top: 34px; padding: 0 22px; border: 0; background: var(--ink); color: #fff; font-weight: 500; cursor: pointer; transition: background .2s, transform .2s; }
.apply-button:hover { background: #a75236; transform: translateY(-2px); }
.apply-button:focus-visible, .danger-button:focus-visible, .neutral-button:focus-visible, .text-button:focus-visible { outline: 3px solid rgba(157,63,50,.35); outline-offset: 3px; }
.apply-button:disabled { cursor: not-allowed; opacity: .45; transform: none; }
.form-message { min-height: 24px; margin: 14px 0 0; color: var(--ink-soft); font-size: 12px; }
.form-message[data-kind="error"] { color: var(--danger); }
.form-message[data-kind="success"] { color: var(--success); }
.disabled-notice { margin-bottom: 24px; padding: 14px 16px; border-left: 3px solid #bc812f; background: #f7e9d2; }
.disabled-notice strong { display: block; font-size: 13px; }
.disabled-notice span { color: var(--ink-soft); font-size: 12px; }

.admin-body { background: var(--paper-deep); }
.admin-shell { width: min(1180px, calc(100% - 80px)); margin: 0 auto; padding: 76px 0 100px; }
.admin-shell h1 { font-size: clamp(42px, 5vw, 66px); }
.admin-login { max-width: 430px; margin: 6vh auto 0; }
.admin-login form { margin-top: 50px; }
.admin-login label, .admin-section label { display: block; margin: 20px 0 8px; color: var(--ink-soft); font-size: 11px; letter-spacing: .06em; }
.admin-login input, .admin-section input, .admin-section select { width: 100%; height: 50px; padding: 0 14px; border: 1px solid var(--line); border-radius: 0; background: rgba(255,255,255,.45); color: var(--ink); outline: none; }
.admin-login input:focus, .admin-section input:focus, .admin-section select:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(23,21,18,.07); }
.admin-title-row { display: flex; justify-content: space-between; align-items: end; margin-bottom: 52px; }
.admin-title-row .eyebrow { margin-bottom: 18px; }
.text-button { padding: 3px 0; border: 0; border-bottom: 1px solid currentColor; background: none; color: var(--ink-soft); font-size: 11px; cursor: pointer; }
.admin-grid { display: grid; grid-template-columns: minmax(300px, .72fr) minmax(450px, 1.28fr); border-top: 1px solid var(--line); }
.admin-section { min-height: 460px; padding: 34px 42px 40px 0; }
.admin-section + .admin-section { padding-left: 42px; border-left: 1px solid var(--line); }
.section-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 36px; }
.section-title > div { display: flex; align-items: baseline; gap: 15px; }
.section-title span { color: var(--ink-soft); font-size: 9px; letter-spacing: .14em; }
.section-title h2 { margin: 0; font-family: var(--display); font-size: 27px; font-weight: 500; }
.lock-badge { padding: 6px 10px; border: 1px solid var(--line); }
.lock-badge[data-state="enabled"] { border-color: rgba(47,104,81,.35); color: var(--success); background: rgba(47,104,81,.06); }
.lock-badge[data-state="disabled"] { border-color: rgba(157,63,50,.35); color: var(--danger); background: rgba(157,63,50,.06); }
.admin-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 30px; }
.danger-button, .neutral-button { min-height: 48px; padding: 0 14px; cursor: pointer; }
.danger-button { border: 0; background: var(--danger); color: #fff; }
.neutral-button { border: 1px solid var(--ink); background: transparent; }
.log-list { max-height: 520px; overflow-y: auto; padding-right: 6px; }
.log-item { display: grid; grid-template-columns: 9px 1fr auto; gap: 14px; align-items: start; padding: 17px 0; border-top: 1px solid var(--line); }
.log-dot { width: 7px; height: 7px; margin-top: 8px; border-radius: 50%; background: var(--danger); }
.log-dot[data-success="true"] { background: var(--success); }
.log-item strong { display: block; font-size: 12px; font-weight: 600; }
.log-item p { margin: 2px 0 0; color: var(--ink-soft); font-size: 11px; }
.log-item time { color: var(--ink-soft); font-size: 10px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.log-empty { color: var(--ink-soft); font-size: 12px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 980px) {
  .site-header, .site-footer, .control-shell, .admin-shell { width: min(100% - 38px, 720px); }
  .control-shell { grid-template-columns: 1fr 1fr; }
  .intro { grid-column: 1 / -1; padding: 62px 0 48px; }
  .intro-copy { max-width: 420px; }
  .lamp-stage { min-height: 560px; }
  .halo { width: min(55vw, 390px); }
  .control-panel { padding: 40px 28px; }
  .admin-grid { grid-template-columns: 1fr; }
  .admin-section { padding-right: 0; }
  .admin-section + .admin-section { padding: 42px 0 0; border-top: 1px solid var(--line); border-left: 0; }
}

@media (max-width: 640px) {
  .site-header, .site-footer, .control-shell, .admin-shell { width: calc(100% - 30px); }
  .site-header { height: 74px; }
  .wordmark span { display: none; }
  .control-shell { display: block; }
  .intro { padding: 46px 5px 42px; }
  .intro h1 { font-size: 46px; }
  .lamp-stage { min-height: 430px; margin-inline: -15px; }
  .halo { width: 72vw; max-width: 340px; }
  .lamp-caption { left: 23px; right: 23px; }
  .control-panel { padding: 46px 4px 64px; }
  .color-line { gap: 14px; }
  .presets { gap: 7px; }
  .presets button { width: 27px; height: 27px; }
  .site-footer span { max-width: 210px; }
  .admin-shell { padding: 52px 0 70px; }
  .admin-title-row { align-items: start; }
  .admin-title-row h1 { font-size: 42px; }
  .admin-section { padding-top: 28px; }
  .section-title { align-items: start; }
  .admin-actions { grid-template-columns: 1fr; }
  .log-item { grid-template-columns: 8px 1fr; }
  .log-item time { grid-column: 2; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
