:root {
  color-scheme: dark;
  --page: #05080a;
  --case: #0a1013;
  --case-2: #0d1519;
  --screen: #020708;
  --line: rgba(86, 224, 239, 0.25);
  --line-strong: rgba(86, 224, 239, 0.55);
  --cyan: #56e0ef;
  --cyan-soft: #b9f8ff;
  --green: #70efaa;
  --capture: #b779ff;
  --warning: #ffd166;
  --danger: #ff6b73;
  --text: #effcfc;
  --muted: #9eb4b6;
  --shadow: rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--page);
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  overflow-x: hidden;
  background-color: var(--page);
  background-image:
    linear-gradient(rgba(86, 224, 239, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(86, 224, 239, 0.025) 1px, transparent 1px);
  background-size: 34px 34px;
  color: var(--text);
  font-family: "Noto Sans JP", "Yu Gothic", "Hiragino Kaku Gothic ProN", system-ui, sans-serif;
  line-height: 1.65;
}

button,
select,
input {
  font: inherit;
}

button {
  min-width: 0;
  border: 0;
  letter-spacing: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--warning);
  outline-offset: 3px;
}

a {
  color: var(--cyan-soft);
  text-underline-offset: 3px;
}

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

.noscript {
  margin: 0;
  padding: 14px;
  background: #53151b;
  color: #fff;
  text-align: center;
}

.page-shell {
  width: min(calc(100% - 36px), 1220px);
  margin: 0 auto;
  padding: 18px 0 30px;
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  min-height: 28px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
}

.device-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 24px;
  align-items: end;
  padding: 12px 0 16px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.series-label,
.section-kicker {
  margin-bottom: 5px;
  color: var(--green);
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

h1 {
  margin-bottom: 2px;
  font-size: 40px;
  line-height: 1.25;
  letter-spacing: 0;
}

.device-name {
  margin-bottom: 8px;
  color: var(--cyan);
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0;
}

.lead {
  max-width: 790px;
  margin-bottom: 0;
  color: #d2e5e6;
  font-size: 15px;
}

.header-readout {
  display: grid;
  gap: 6px;
}

.header-readout span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 31px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  background: rgba(86, 224, 239, 0.035);
  color: var(--muted);
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 12px;
  font-weight: 700;
}

.header-readout span.active {
  border-color: var(--line-strong);
  color: var(--cyan-soft);
}

.recorder-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 16px;
  margin-top: 16px;
}

.monitor-column,
.side-column {
  min-width: 0;
}

.stage-monitor,
.phase-panel,
.log-panel,
.review-section {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--case);
  box-shadow: 0 18px 44px var(--shadow);
}

.stage-monitor {
  position: relative;
  overflow: hidden;
}

.stage-monitor::before,
.phase-panel::before,
.log-panel::before,
.review-section::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--cyan);
  content: "";
  pointer-events: none;
}

.stage-monitor.captured::before,
.signal-card::before {
  background: var(--capture);
}

.monitor-head,
.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 42px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--cyan);
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 12px;
  font-weight: 800;
}

.monitor-head span:last-child,
.panel-heading > span {
  color: var(--muted);
}

.stage-copy {
  display: grid;
  place-items: center;
  min-height: 206px;
  padding: 20px 16px 16px;
  text-align: center;
}

.stage-kicker {
  margin-bottom: 2px;
  color: var(--green);
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 13px;
  font-weight: 800;
}

.stage-copy h2 {
  max-width: 24ch;
  margin-bottom: 4px;
  font-size: 25px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.countdown {
  min-height: 92px;
  margin-bottom: 4px;
  color: var(--cyan-soft);
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 72px;
  font-weight: 900;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.stage-description {
  min-height: 27px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
}

.wave-screen {
  position: relative;
  min-height: 170px;
  overflow: hidden;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--screen);
}

.wave-screen canvas,
.screen-grid {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.screen-grid {
  z-index: 1;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(86, 224, 239, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(86, 224, 239, 0.08) 1px, transparent 1px);
  background-size: 28px 28px;
}

#liveWaveform {
  z-index: 2;
}

.capture-flash {
  position: absolute;
  z-index: 3;
  left: 50%;
  top: 50%;
  width: min(88%, 360px);
  transform: translate(-50%, -50%);
  padding: 13px;
  border: 1px solid var(--capture);
  background: rgba(34, 12, 49, 0.9);
  color: #f0ddff;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-weight: 900;
  text-align: center;
}

.session-progress {
  height: 7px;
  background: #030607;
}

.session-progress span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--cyan);
  transition: width 160ms linear;
}

.monitor-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--line);
}

.monitor-metrics span {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 10px 12px;
  color: var(--muted);
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 11px;
}

.monitor-metrics span + span {
  border-left: 1px solid var(--line);
}

.monitor-metrics strong {
  color: var(--text);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.primary-actions {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 130px 130px;
  gap: 8px;
  margin-top: 10px;
}

.primary-button,
.secondary-button,
.play-button,
.save-button,
.control-group button {
  min-height: 48px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  font-weight: 800;
}

.primary-button {
  background: var(--cyan);
  color: #031114;
}

.secondary-button,
.play-button,
.save-button,
.control-group button {
  background: #10191d;
  color: var(--text);
}

.primary-button:hover:not(:disabled),
.secondary-button:hover:not(:disabled),
.play-button:hover:not(:disabled),
.save-button:hover:not(:disabled),
.control-group button:hover:not(:disabled) {
  border-color: var(--cyan-soft);
  filter: brightness(1.12);
}

.privacy-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.status-message {
  display: flex;
  align-items: center;
  min-height: 50px;
  margin-top: 8px;
  padding: 8px 12px;
  border-left: 3px solid var(--cyan);
  background: rgba(86, 224, 239, 0.055);
  color: #d9f3f4;
  font-size: 14px;
}

.status-message.error {
  border-left-color: var(--danger);
  background: rgba(255, 107, 115, 0.08);
  color: #ffd7da;
}

.side-column {
  display: grid;
  gap: 14px;
  align-content: start;
}

.phase-panel,
.log-panel {
  position: relative;
  overflow: hidden;
}

.panel-heading h2 {
  margin: 0;
  font-size: 14px;
  letter-spacing: 0;
}

.phase-list,
.device-log {
  margin: 0;
  padding: 0;
  list-style: none;
}

.phase-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0 10px;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}

.phase-list li:last-child {
  border-bottom: 0;
}

.phase-list strong {
  min-width: 0;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.phase-list span {
  font-size: 12px;
  font-weight: 800;
}

.phase-list small {
  grid-column: 1 / -1;
  margin-top: 2px;
  color: #829698;
  font-size: 11px;
}

.phase-list li.active {
  background: rgba(86, 224, 239, 0.09);
  color: var(--cyan-soft);
}

.phase-list li.done {
  color: var(--green);
}

.phase-list li.captured {
  color: #e8d5ff;
}

.device-log {
  max-height: 312px;
  overflow: auto;
}

.device-log li {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 8px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  color: #cadcdd;
  font-size: 12px;
}

.device-log time {
  color: var(--cyan);
  font-family: Consolas, "SFMono-Regular", monospace;
}

.review-section {
  position: relative;
  margin-top: 18px;
  overflow: hidden;
}

.review-heading-row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 22px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.review-heading-row h2 {
  margin-bottom: 0;
  font-size: 24px;
}

.review-heading-row > p {
  max-width: 560px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
}

.review-empty {
  display: grid;
  place-items: center;
  gap: 5px;
  min-height: 150px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.review-empty strong {
  color: var(--cyan);
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 18px;
}

.review-empty.no-signal strong {
  color: var(--green);
}

.signal-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.signal-card {
  position: relative;
  min-width: 0;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: #0a1013;
}

.signal-card:nth-child(odd) {
  border-right: 1px solid var(--line);
}

.signal-card::before {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  content: "";
}

.signal-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.signal-number {
  margin-bottom: 2px;
  color: var(--capture);
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 13px;
  font-weight: 900;
}

.signal-time {
  margin-bottom: 0;
  font-size: 20px;
}

.signal-strength {
  min-width: 66px;
  padding: 6px 8px;
  border: 1px solid var(--capture);
  color: #eadbff;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-weight: 900;
  text-align: center;
}

.signal-visuals {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.signal-visuals figure {
  margin-bottom: 0;
}

.signal-visuals figcaption {
  margin-bottom: 4px;
  color: var(--muted);
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 11px;
}

.signal-visuals canvas {
  display: block;
  width: 100%;
  height: 94px;
  border: 1px solid var(--line);
  background: var(--screen);
}

.signal-controls {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) minmax(0, 1fr) 104px;
  gap: 8px;
  align-items: stretch;
  margin-top: 12px;
}

.control-group {
  display: grid;
  grid-template-columns: auto repeat(3, minmax(38px, 1fr));
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 5px;
  overflow: hidden;
}

.control-group span {
  display: grid;
  place-items: center;
  padding: 0 7px;
  color: var(--muted);
  font-size: 11px;
}

.control-group button {
  min-height: 46px;
  border-width: 0 0 0 1px;
  border-radius: 0;
  font-size: 12px;
}

.control-group button[aria-pressed="true"] {
  background: var(--cyan);
  color: #031114;
}

.clip-range {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.device-notes {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 24px;
  margin-top: 20px;
  padding: 20px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.device-notes h2 {
  margin-bottom: 0;
  font-size: 23px;
}

.notes-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid var(--line);
}

.notes-grid article {
  min-width: 0;
  padding: 14px;
}

.notes-grid article + article {
  border-left: 1px solid var(--line);
}

.notes-grid h3 {
  margin-bottom: 5px;
  color: var(--cyan-soft);
  font-size: 15px;
}

.notes-grid p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
}

.ad-reservation {
  display: grid;
  place-items: center;
  min-height: 96px;
  margin-top: 16px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: #64777a;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 10px;
  letter-spacing: 0;
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 0 0;
  color: var(--muted);
  font-size: 12px;
}

[hidden] {
  display: none !important;
}

@media (max-width: 1050px) {
  .recorder-shell {
    grid-template-columns: minmax(0, 1fr) 270px;
  }

  .primary-actions {
    grid-template-columns: minmax(160px, 1fr) 110px 110px;
  }

  .signal-list {
    grid-template-columns: 1fr;
  }

  .signal-card:nth-child(odd) {
    border-right: 0;
  }
}

@media (max-width: 880px) {
  .device-header {
    grid-template-columns: 1fr;
  }

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

  .recorder-shell {
    grid-template-columns: 1fr;
  }

  .side-column {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .device-notes {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .page-shell {
    width: min(calc(100% - 24px), 1220px);
    padding-top: 10px;
  }

  h1 {
    font-size: 28px;
    line-height: 1.35;
  }

  .device-name {
    font-size: 16px;
  }

  .lead {
    font-size: 14px;
  }

  .header-readout {
    gap: 4px;
  }

  .header-readout span {
    min-height: 28px;
    padding: 3px 4px;
    font-size: 10px;
  }

  .stage-copy {
    min-height: 174px;
    padding: 14px 10px 10px;
  }

  .stage-copy h2 {
    font-size: 21px;
  }

  .countdown {
    min-height: 66px;
    font-size: 48px;
  }

  .stage-description {
    min-height: 44px;
    font-size: 13px;
  }

  .wave-screen {
    min-height: 138px;
  }

  .primary-actions {
    grid-template-columns: 1fr 1fr;
  }

  .primary-button {
    grid-column: 1 / -1;
  }

  .primary-button,
  .secondary-button {
    min-height: 50px;
  }

  .side-column {
    grid-template-columns: 1fr;
  }

  .phase-panel {
    order: 1;
  }

  .log-panel {
    order: 2;
  }

  .device-log {
    max-height: 190px;
  }

  .review-heading-row {
    display: grid;
    gap: 8px;
    padding: 15px;
  }

  .review-heading-row h2 {
    font-size: 21px;
  }

  .signal-card {
    padding: 13px;
  }

  .signal-controls {
    grid-template-columns: 1fr 1fr;
  }

  .control-group {
    grid-column: 1 / -1;
  }

  .play-button,
  .save-button {
    min-height: 48px;
  }

  .notes-grid {
    grid-template-columns: 1fr;
  }

  .notes-grid article + article {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .site-footer {
    display: grid;
  }
}

@media (max-width: 390px) {
  .page-shell {
    width: min(calc(100% - 16px), 1220px);
  }

  .breadcrumb {
    font-size: 11px;
  }

  .series-label {
    font-size: 11px;
  }

  .monitor-head,
  .panel-heading {
    padding-right: 10px;
    padding-left: 10px;
  }

  .stage-copy h2 {
    max-width: 18ch;
  }

  .monitor-metrics span {
    padding: 8px 6px;
    font-size: 9px;
  }

  .monitor-metrics strong {
    font-size: 12px;
  }

  .status-message {
    min-height: 60px;
  }
}

@media (max-width: 340px) {
  h1 {
    font-size: 27px;
  }

  .device-header {
    gap: 14px;
  }

  .header-readout {
    grid-template-columns: 1fr;
  }

  .header-readout span {
    min-height: 25px;
  }

  .stage-copy h2 {
    font-size: 19px;
  }

  .signal-card-head {
    align-items: start;
  }

  .control-group {
    grid-template-columns: 48px repeat(3, minmax(0, 1fr));
  }

  .control-group span {
    padding: 0 4px;
  }
}

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

/* Keep the shared comment widget inside the recorder's dark instrument theme. */
.comments-section {
  color: var(--text);
}

.comments-section :is(.app-comments, .app-comment-form-section) {
  border-color: var(--line-strong);
  background: var(--case);
  box-shadow: 0 18px 44px var(--shadow);
}

.comments-section :is(.app-comments h2, .app-comment-form-section h2) {
  color: var(--cyan-soft);
}

.comments-section :is(
  .app-comment-summary,
  .app-comment-meta,
  .app-comment-page-status,
  .app-comments-empty,
  .app-comment-message
) {
  color: var(--muted);
}

.comments-section :is(.app-comment-card, .app-comment-pagination) {
  border-color: var(--line);
}

.comments-section .app-comment-rating {
  color: var(--warning);
}

.comments-section :is(.app-comment-admin-reply, .app-comment-reply) {
  background: rgba(86, 224, 239, 0.055);
}

.comments-section .app-comment-admin-reply {
  border-left-color: var(--cyan);
}

.comments-section .app-comment-admin-reply-title,
.comments-section .app-comment-reply-form-wrap summary {
  color: var(--cyan);
}

.comments-section .app-comment-admin-reply-date {
  color: var(--muted);
}

.comments-section .app-comment-replies {
  border-left-color: var(--line-strong);
}

.comments-section .app-comment-pagination :is(a, span) {
  border-color: var(--line-strong);
  color: var(--cyan-soft);
}

.comments-section .app-comment-pagination span {
  border-color: var(--cyan);
  background: var(--cyan);
  color: #031114;
}

.comments-section .app-comment-form label {
  color: var(--cyan-soft);
}

.comments-section .app-comment-form :is(input, select, textarea) {
  min-height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--screen);
  color: var(--text);
  padding: 9px 11px;
}

.comments-section .app-comment-form textarea {
  min-height: 128px;
  resize: vertical;
}

.comments-section .app-comment-form :is(input, textarea)::placeholder {
  color: #829698;
  opacity: 1;
}

.comments-section .app-comment-form :is(input, select, textarea):focus-visible {
  outline: 3px solid var(--warning);
  outline-offset: 2px;
}

.comments-section .app-comment-form button {
  min-height: 44px;
  border-color: var(--cyan);
  border-radius: 5px;
  background: var(--cyan);
  color: #031114;
  padding: 9px 16px;
}

.comments-section .app-comment-form button:hover,
.comments-section .app-comment-form button:focus-visible {
  border-color: var(--cyan-soft);
  background: var(--cyan-soft);
  color: #031114;
}
