/* ============ NAITHON·ONE — radio terminal ============ */
:root{
  --primary:#4D3A2B;
  --secondary:#2A1E16;
  --tertiary:#443427;
  --neutral:#1A140F;
  --text-primary:#755A30;
  --text-secondary:#C8A96E;
  --text-bright:#F2E1C1;
  --button-bg:#443427;
  --button-text:#9C846D;
  --accent-bg:#755A30;
  --accent-text:#F2E1C1;

  --r-md:6px;
  --r-lg:8px;
  --r-xl:12px;
  --r-2xl:24px;
  --r-pill:9999px;

  --shadow-card:
    rgba(0,0,0,0.9) 0 60px 100px -20px,
    rgb(30,22,16) 0 12px 0 0,
    rgba(0,0,0,0.6) 0 13px 4px 0,
    rgba(255,230,200,0.15) 0 1px 1px 0 inset,
    rgba(0,0,0,0.4) 0 -1px 2px 0 inset;
  --shadow-screen:
    rgba(0,0,0,0.9) 0 4px 12px 0 inset,
    rgb(0,0,0) 0 0 0 1px inset,
    rgba(255,230,200,0.05) 0 1px 1px 0;
  --shadow-btn:
    rgba(0,0,0,0.5) 0 3px 6px 0,
    rgba(255,255,255,0.05) 0 1px 1px 0 inset,
    rgba(0,0,0,0.3) 0 -1px 2px 0 inset;
  --shadow-btn-active:
    rgba(0,0,0,0.6) 0 2px 6px 0 inset,
    rgba(117,90,48,0.4) 0 0 8px 0;

  --mono: "SFMono-Regular", ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

*{ box-sizing:border-box; margin:0; }
html,body{ height:100%; }
body{
  font-family: var(--mono);
  color: var(--text-secondary);
  letter-spacing: 0.1em;
  font-size: 12px;
  line-height: 16px;
  font-weight: 300;
  background:
    radial-gradient(120% 90% at 50% 45%, #3A2C20 0%, #2A1E16 40%, #1A140F 80%, #0F0A07 100%);
  min-height: 100svh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* Subtle background grain via CSS gradient noise */
body::before{
  content:"";
  position: fixed; inset:0;
  background-image:
    radial-gradient(rgba(255,230,200,0.025) 1px, transparent 1px);
  background-size: 3px 3px;
  pointer-events:none;
  z-index: 0;
  mix-blend-mode: overlay;
}

/* Vignette */
body::after{
  content:"";
  position: fixed; inset:0;
  background: radial-gradient(80% 60% at 50% 50%, transparent 50%, rgba(0,0,0,0.55) 100%);
  pointer-events:none;
  z-index: 0;
}

.stage{
  position: relative;
  z-index: 1;
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 24px;
  gap: 20px;
}

/* ========== BRAND ========== */
.brand{
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-bright);
  font-weight: 500;
  letter-spacing: 0.25em;
  font-size: 11px;
  opacity: 0.85;
}
.brand__dot{
  width: 8px; height: 8px; border-radius: 50%;
  background: #C8A96E;
  box-shadow: 0 0 8px #C8A96E, 0 0 16px rgba(200,169,110,0.4);
  animation: blink 2.4s ease-in-out infinite;
}
.brand__name{ color: var(--text-bright); }
.brand__sub{ opacity: 0.5; font-weight: 300; }
@keyframes blink{ 0%,100%{opacity:1} 50%{opacity:.35} }

/* ========== SHELL (gradient border) ========== */
.shell{
  align-self: center;
  justify-self: center;
  padding: 2px;
  border-radius: 28px;
  background:
    repeating-radial-gradient(
      circle,
      rgb(253,250,240) 0px,
      rgb(253,250,240) 1px,
      rgb(226,209,176) 1.5px,
      rgb(226,209,176) 2.5px
    );
  box-shadow:
    0 0 0 1px rgba(0,0,0,0.3),
    var(--shadow-card);
  max-width: min(960px, 100%);
  width: 100%;
}
.shell__inner{
  background: var(--primary);
  border-radius: 26px;
  padding: 24px;
  position: relative;
}

/* ========== PANEL ========== */
.panel{
  position: relative;
  background:
    linear-gradient(180deg, #54402F 0%, #4A3829 60%, #3F2F23 100%);
  border-radius: var(--r-2xl);
  padding: 18px 20px 22px;
  box-shadow:
    inset 0 1px 1px rgba(255,230,200,0.15),
    inset 0 -1px 2px rgba(0,0,0,0.4),
    0 3px 6px rgba(0,0,0,0.5);
  overflow: hidden;
}
.grain{
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  pointer-events:none;
  mix-blend-mode: soft-light;
  opacity: 0.5;
  border-radius: inherit;
}
.panel__topbar{
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  position: relative;
  z-index: 2;
}
.panel__label{
  color: #6E5640;
  font-weight: 500;
  letter-spacing: 0.2em;
  font-size: 10px;
}
.panel__led{
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #E1B468;
  box-shadow:
    0 0 6px rgba(255,200,120,0.7),
    inset 0 -1px 1px rgba(0,0,0,0.4);
}

.panel__grid{
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 180px 88px;
  gap: 20px;
  align-items: stretch;
  position: relative;
  z-index: 2;
}

/* ========== SCOPE (left screen) ========== */
.scope{
  background: var(--secondary);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  box-shadow: var(--shadow-screen);
  position: relative;
  min-height: 220px;
  overflow: hidden;
}
.scope__inner{
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 8px;
}
.scope__corners{
  display: flex;
  justify-content: space-between;
  color: #6E552E;
  font-size: 10px;
  letter-spacing: 0.15em;
  position: relative;
  z-index: 2;
}
.scope__canvas{
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  z-index: 2;
  transition: opacity 240ms ease;
}
.scope__canvas.is-dim{ opacity: 0.08; }
.scope__noise{
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  z-index: 1;
  pointer-events: none;
  mix-blend-mode: overlay;
  opacity: 0.55;
}
.scope__readout{
  position: relative;
  z-index: 3;
  align-self: end;
  padding-bottom: 4px;
}
.scope__big{
  font-size: 44px;
  line-height: 44px;
  font-weight: 200;
  letter-spacing: -0.025em;
  color: var(--text-bright);
  text-shadow: 0 0 8px rgba(241,201,124,0.45);
}
.scope__pct{ font-size: 22px; opacity: 0.85; }
.scope__caption{
  color: var(--text-secondary);
  margin-top: 4px;
  font-size: 10px;
  letter-spacing: 0.2em;
}
.scope__bottom{
  position: relative;
  z-index: 3;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  border-top: 1px dashed rgba(200,169,110,0.18);
  padding-top: 6px;
}
.scope__metric{ display: flex; flex-direction: column; gap: 2px; }
.scope__metric--right{ align-items: flex-end; }
.scope__metric-label{
  color: #7C6437;
  font-size: 10px;
  letter-spacing: 0.2em;
}
.scope__metric-value{
  color: var(--text-bright);
  font-size: 18px;
  line-height: 18px;
  font-weight: 200;
}
.scope__metric-value .unit{ font-size: 11px; opacity: 0.65; }
.scope__city{
  position: absolute;
  top: -2px; left: 50%;
  transform: translateX(-50%);
  color: var(--text-bright);
  text-shadow: 0 0 6px rgba(241,201,124,0.35);
  font-size: 11px;
  letter-spacing: 0.25em;
  z-index: 4;
  white-space: nowrap;
  max-width: calc(100% - 130px);
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ----- karaoke overlay inside the scope screen ----- */
.scope__lyrics{
  position: absolute;
  left: 14px;
  right: 14px;
  top: 30px;
  bottom: 36px;
  z-index: 4;
  display: grid;
  grid-template-rows: 1fr auto 1fr;
  align-items: center;
  justify-items: center;
  text-align: center;
  pointer-events: none;
  font-family: var(--mono);
  letter-spacing: 0.05em;
  opacity: 0;
  transition: opacity 240ms ease;
}
.scope__lyrics[data-state="ready"]{ opacity: 1; }
.scope__lyrics-line{
  color: var(--text-bright);
  max-width: 100%;
  padding: 0 6px;
  transition:
    opacity 320ms cubic-bezier(0.4,0,0.2,1),
    transform 320ms cubic-bezier(0.4,0,0.2,1),
    filter 320ms cubic-bezier(0.4,0,0.2,1);
  text-wrap: balance;
}
.scope__lyrics-line--prev{
  align-self: end;
  font-size: 11px;
  line-height: 1.25;
  opacity: 0.32;
  filter: blur(0.4px);
  transform: translateY(4px);
}
.scope__lyrics-line--active{
  font-size: 17px;
  line-height: 1.2;
  font-weight: 500;
  letter-spacing: 0.03em;
  opacity: 1;
  text-shadow:
    0 0 10px rgba(241,201,124,0.55),
    0 0 22px rgba(241,201,124,0.22);
}
/* "gap" — instrumental break, show upcoming line as a soft ghost */
.scope__lyrics-line--active.is-gap{
  font-size: 13px;
  font-weight: 400;
  opacity: 0.42;
  filter: blur(0.3px);
  text-shadow: none;
}
.scope__lyrics-line--next{
  align-self: start;
  font-size: 11px;
  line-height: 1.25;
  opacity: 0.28;
  filter: blur(0.4px);
  transform: translateY(-4px);
}
.scope__lyrics-word{
  display: inline-block;
  color: rgba(200,169,110,0.65);
  transition: color 90ms ease, text-shadow 90ms ease;
  margin-right: 0.22em;
}
.scope__lyrics-line--active .scope__lyrics-word--done{ color: #F2E1C1; }
.scope__lyrics-line--active .scope__lyrics-word--now{
  color: #FFFCEF;
  text-shadow:
    0 0 8px rgba(255,235,180,0.85),
    0 0 18px rgba(241,201,124,0.55);
}
/* fade out the existing big readout when subtitles are active */
.scope__readout{
  transition: opacity 240ms ease;
}
.scope__readout.is-dim{ opacity: 0.08; }

@media (max-width: 720px){
  .scope__lyrics{ left: 10px; right: 10px; top: 24px; bottom: 30px; }
  .scope__lyrics-line--active{ font-size: 14px; }
  .scope__lyrics-line--prev,
  .scope__lyrics-line--next{ font-size: 9px; }
}

/* CRT scanline + glow */
.scope::before{
  content:"";
  position: absolute; inset:0;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(0,0,0,0.0) 0px,
      rgba(0,0,0,0.0) 2px,
      rgba(0,0,0,0.18) 3px
    );
  pointer-events:none;
  z-index: 2;
  mix-blend-mode: multiply;
}
.scope::after{
  content:"";
  position: absolute; inset:0;
  background: radial-gradient(70% 60% at 50% 40%, rgba(255,220,160,0.05) 0%, transparent 60%);
  pointer-events:none;
  z-index: 2;
}

/* ========== DIAL ========== */
.dial-wrap{
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 8px;
  user-select: none;
}
.dial{
  width: 140px; height: 140px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 38%, #FFFDF5 0%, #F0E6CC 55%, #C9B68A 100%);
  position: relative;
  cursor: grab;
  box-shadow:
    0 12px 24px rgba(0,0,0,0.55),
    0 4px 8px rgba(0,0,0,0.45),
    inset 0 -6px 12px rgba(0,0,0,0.18),
    inset 0 6px 12px rgba(255,255,255,0.6);
  outline: none;
  touch-action: none;
}
.dial:focus-visible{
  box-shadow:
    0 0 0 3px rgba(200,169,110,0.55),
    0 12px 24px rgba(0,0,0,0.55),
    inset 0 -6px 12px rgba(0,0,0,0.18),
    inset 0 6px 12px rgba(255,255,255,0.6);
}
.dial:active{ cursor: grabbing; }
.dial__rings{
  position: absolute; inset: 0;
  border-radius: 50%;
  background:
    repeating-radial-gradient(
      circle at 50% 50%,
      rgba(0,0,0,0.12) 0px,
      rgba(0,0,0,0.12) 1px,
      transparent 1.5px,
      transparent 4px
    );
  mask: radial-gradient(circle at 50% 50%, black 0%, black 78%, transparent 80%);
}
.dial__pointer{
  position: absolute;
  top: 8px; left: 50%;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #2A1E16;
  transform: translateX(-50%);
  box-shadow: 0 1px 2px rgba(0,0,0,0.4);
}
.dial__caption{
  color: #6E5640;
  font-size: 10px;
  letter-spacing: 0.25em;
  margin-top: 4px;
}
.dial__hint{
  color: #5A4631;
  font-size: 9px;
  letter-spacing: 0.2em;
  opacity: 0.6;
}

/* ========== ACTIONS ========== */
.actions{
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
  justify-content: center;
}
.btn{
  background: var(--button-bg);
  color: var(--button-text);
  border: 0;
  border-radius: var(--r-md);
  padding: 14px 0;
  font-family: var(--mono);
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 0.15em;
  box-shadow: var(--shadow-btn);
  cursor: pointer;
  transition: color 100ms ease, background-color 100ms ease;
  min-height: 44px;
}
.btn:hover{ color: var(--text-bright); }
.btn--active{
  background: var(--accent-bg);
  color: var(--accent-text);
  box-shadow: var(--shadow-btn-active);
}

/* ========== STATION TICKS ========== */
.ticks{
  position: relative;
  margin-top: 18px;
  height: 36px;
  background:
    linear-gradient(180deg, rgba(0,0,0,0.25) 0%, rgba(0,0,0,0.05) 100%);
  border-radius: var(--r-md);
  box-shadow:
    inset 0 1px 2px rgba(0,0,0,0.45),
    inset 0 -1px 1px rgba(255,230,200,0.08);
  padding: 6px 12px;
  display: flex;
  align-items: center;
  z-index: 2;
}
.tick{
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: #7C6437;
  font-size: 10px;
  letter-spacing: 0.18em;
  cursor: pointer;
  transition: color 100ms ease;
  position: relative;
  background: transparent;
  border: 0;
  padding: 0 2px;
  font-family: var(--mono);
  font-weight: 500;
  min-width: 0;
}
.tick:hover{ color: var(--text-bright); }
.tick__bar{
  width: 1px;
  height: 10px;
  background: rgba(200,169,110,0.4);
}
.tick--active{ color: var(--text-bright); }
.tick--active .tick__bar{
  background: var(--text-bright);
  box-shadow: 0 0 6px rgba(241,201,124,0.6);
  height: 14px;
}

/* ========== PLAY ROW ========== */
.play-row{
  display: flex;
  gap: 12px;
  align-items: stretch;
  margin-top: 18px;
}
.play{
  background: var(--accent-bg);
  color: var(--accent-text);
  border: 0;
  border-radius: var(--r-md);
  padding: 14px 22px;
  font-family: var(--mono);
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 0.2em;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  box-shadow: var(--shadow-btn-active);
  min-height: 48px;
}
.play[data-on="false"]{
  background: var(--button-bg);
  color: var(--button-text);
  box-shadow: var(--shadow-btn);
}
.play__icon{
  width: 12px; height: 12px;
  background: currentColor;
  clip-path: polygon(0 0, 100% 50%, 0 100%);
}
.play[data-on="true"] .play__icon{
  clip-path: polygon(0 0, 35% 0, 35% 100%, 0 100%, 65% 100%, 65% 0, 100% 0, 100% 100%, 65% 100%);
  background: transparent;
  border-left: 4px solid currentColor;
  border-right: 4px solid currentColor;
  width: 12px;
  height: 14px;
  clip-path: none;
}
.play__meta{
  flex: 1;
  background: var(--secondary);
  border-radius: var(--r-md);
  padding: 8px 14px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  box-shadow: var(--shadow-screen);
}
.play__meta-label{
  color: #7C6437;
  font-size: 10px;
  letter-spacing: 0.2em;
}
.play__meta-value{
  color: var(--text-bright);
  font-size: 12px;
  letter-spacing: 0.2em;
  margin-top: 2px;
}

/* ========== FOOTER ========== */
.footer{
  color: #6E5640;
  font-size: 10px;
  letter-spacing: 0.25em;
  display: flex;
  justify-content: center;
  gap: 8px;
  opacity: 0.65;
  flex-wrap: wrap;
  text-align: center;
}
.footer__dot{ opacity: 0.4; }

/* ============ Responsive ============ */
@media (max-width: 720px){
  body{ overflow: auto; }
  .stage{ padding: 12px; gap: 10px; }
  .shell__inner{ padding: 12px; border-radius: 22px; }
  .shell{ border-radius: 24px; }
  .panel{ padding: 12px 12px 14px; }
  .panel__topbar{ margin-bottom: 8px; }
  .panel__grid{
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    gap: 12px;
  }
  .scope{ min-height: 170px; padding: 10px 12px; }
  .scope__corners{ font-size: 9px; }
  .scope__big{ font-size: 38px; line-height: 38px; }
  .scope__pct{ font-size: 18px; }
  .scope__caption{ font-size: 9px; }
  .scope__metric-value{ font-size: 16px; }
  .scope__city{
    position: static;
    transform: none;
    text-align: center;
    max-width: none;
    font-size: 10px;
    letter-spacing: 0.18em;
    margin-bottom: 2px;
  }
  .scope__corners{ display: none; }
  .scope__inner{ grid-template-rows: auto 1fr auto; }
  .dial-wrap{ gap: 4px; }
  .dial{ width: 110px; height: 110px; }
  .dial__caption{ font-size: 9px; }
  .dial__hint{ display: none; }
  .actions{
    flex-direction: row;
    gap: 6px;
  }
  .actions .btn{ flex: 1; padding: 11px 0; min-height: 40px; font-size: 11px; }
  .ticks{ height: 30px; padding: 4px 6px; margin-top: 12px; }
  .tick{ font-size: 9px; letter-spacing: 0.1em; gap: 2px; }
  .tick__bar{ height: 8px; }
  .tick--active .tick__bar{ height: 11px; }
  .play-row{ flex-direction: row; gap: 8px; margin-top: 10px; }
  .play{ padding: 10px 14px; font-size: 11px; min-height: 42px; letter-spacing: 0.15em; }
  .play__meta{ padding: 6px 10px; }
  .play__meta-label{ font-size: 9px; }
  .play__meta-value{ font-size: 11px; }
  .brand{ font-size: 10px; gap: 8px; }
  .brand__sub{ display: none; }
  .footer{ font-size: 9px; letter-spacing: 0.18em; }
}

@media (max-width: 380px){
  .scope__big{ font-size: 32px; line-height: 32px; }
  .scope__metric-value{ font-size: 14px; }
  .dial{ width: 100px; height: 100px; }
  .play__meta-value{ font-size: 10px; }
}

@media (prefers-reduced-motion: reduce){
  .brand__dot{ animation: none; }
}
