:root {
  --paper: #f8f5ef;
  --paper-2: #efe7dc;
  --ink: #111111;
  --ink-2: #25211c;
  --muted: #6f665b;
  --soft: #9d9387;
  --gold: #bf9852;
  --gold-2: #e5c77c;
  --line: rgba(17, 17, 17, .10);
  --good: #276749;
  --good-bg: #e7f3ea;
  --warn: #8a5b11;
  --warn-bg: #fff3d8;
  --danger: #a4372a;
  --shadow: 0 24px 70px rgba(39, 30, 18, .12);
  --radius: 24px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--paper-2);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { border: 0; }
.is-hidden { display: none !important; }

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    radial-gradient(circle at 18% 4%, rgba(229, 199, 124, .30), transparent 33%),
    linear-gradient(145deg, #fdfbf7, var(--paper-2));
}
.login-card {
  width: min(470px, 100%);
  padding: clamp(30px, 6vw, 50px);
  background: rgba(248, 245, 239, .94);
  border: 1px solid rgba(17, 17, 17, .09);
  border-radius: 32px;
  box-shadow: 0 34px 100px rgba(39, 30, 18, .17);
  backdrop-filter: blur(20px);
}
.brand-mark {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: var(--gold-2);
  border-radius: 22px;
  font-weight: 800;
  letter-spacing: .08em;
  box-shadow: 0 15px 34px rgba(17, 17, 17, .22);
}
.brand-mark-small { width: 46px; height: 46px; border-radius: 14px; font-size: 13px; box-shadow: none; flex: 0 0 auto; }
.eyebrow {
  margin: 0 0 9px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.login-card .eyebrow { margin-top: 28px; }
.login-card h1 { margin: 0; font-size: clamp(38px, 8vw, 58px); letter-spacing: -.055em; line-height: .98; }
.login-lead { margin: 18px 0 30px; color: var(--muted); line-height: 1.6; }
.form-stack { display: grid; gap: 17px; }
label { display: grid; gap: 8px; min-width: 0; }
label > span { color: var(--ink-2); font-size: 13px; font-weight: 700; }
input, select, textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  padding: 14px 15px;
  outline: none;
  transition: border-color .2s, box-shadow .2s, transform .2s;
}
input:focus, select:focus, textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(191, 152, 82, .15); }
textarea { resize: vertical; line-height: 1.55; }
.form-error { min-height: 20px; margin: 0; color: var(--danger); font-size: 13px; }
.form-hint { color: var(--muted); font-size: 13px; line-height: 1.55; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 11px 17px;
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
  font-size: 14px;
  font-weight: 750;
  transition: transform .18s, box-shadow .18s, background .18s, opacity .18s;
}
.button:hover { transform: translateY(-1px); }
.button:active { transform: translateY(0); }
.button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.button-wide { width: 100%; }
.button-dark { background: var(--ink); color: #fff; box-shadow: 0 10px 24px rgba(17, 17, 17, .16); }
.button-gold { background: linear-gradient(135deg, var(--gold-2), var(--gold)); color: #17120c; box-shadow: 0 12px 30px rgba(191, 152, 82, .27); }
.button-outline { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.button-quiet { background: rgba(17, 17, 17, .05); color: var(--ink); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 24px;
  background: rgba(248, 245, 239, .88);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(22px);
}
.brand { display: flex; align-items: center; gap: 13px; color: var(--ink); text-decoration: none; min-width: 0; }
.brand > span:last-child { min-width: 0; }
.brand strong, .brand small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand strong { font-size: 17px; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 12px; }
.topbar-actions { display: flex; align-items: center; gap: 11px; }

.app-layout { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: calc(100vh - 78px); }
.sidebar {
  position: sticky;
  top: 78px;
  align-self: start;
  height: calc(100vh - 78px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 24px 17px;
  border-right: 1px solid var(--line);
  background: rgba(248, 245, 239, .72);
}
.sidebar nav { display: grid; gap: 7px; }
.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 13px;
  border-radius: 14px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  font-weight: 700;
}
.nav-item:hover { background: rgba(17, 17, 17, .045); color: var(--ink); }
.nav-item.is-active { background: var(--ink); color: #fff; }
.nav-icon { width: 22px; font-size: 18px; text-align: center; }
.sidebar-foot { display: grid; gap: 6px; padding: 13px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.sidebar-foot strong { color: var(--ink); }

.content { width: 100%; min-width: 0; max-width: 1540px; padding: clamp(22px, 4vw, 52px); margin: 0 auto; }
.view { animation: viewIn .28s ease both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

.hero-panel {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 30px;
  min-height: 275px;
  padding: clamp(30px, 5vw, 56px);
  border-radius: 30px;
  background:
    radial-gradient(circle at 83% 12%, rgba(229, 199, 124, .28), transparent 35%),
    linear-gradient(145deg, #111, #211b14);
  color: #fff;
  box-shadow: 0 30px 90px rgba(17, 17, 17, .2);
}
.hero-panel::after { content: "HJG"; position: absolute; right: 4%; bottom: -16%; color: rgba(255,255,255,.035); font-size: 190px; font-weight: 900; letter-spacing: -.08em; pointer-events: none; }
.hero-panel > * { position: relative; z-index: 1; }
.hero-panel h2 { max-width: 780px; margin: 0 0 16px; font-size: clamp(38px, 6vw, 72px); line-height: .98; letter-spacing: -.055em; }
.hero-panel p:not(.eyebrow) { max-width: 680px; margin: 0; color: #cfc8bd; font-size: 17px; line-height: 1.62; }
.notice { margin-top: 24px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 20px 22px; border-radius: 18px; }
.notice p { margin: 4px 0 0; color: var(--muted); }
.notice-gold { background: var(--warn-bg); border: 1px solid rgba(191, 152, 82, .34); }

.metrics-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin: 25px 0 42px; }
.metric { padding: 22px; background: rgba(248, 245, 239, .86); border: 1px solid var(--line); border-radius: 20px; }
.metric span { display: block; color: var(--muted); font-size: 12px; font-weight: 700; }
.metric strong { display: block; margin-top: 10px; font-size: 28px; letter-spacing: -.04em; }
.section-head, .page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin: 0 0 20px; }
.section-head h3, .page-head h2 { margin: 0; letter-spacing: -.035em; }
.section-head h3 { font-size: 30px; }
.page-head h2 { font-size: clamp(34px, 5vw, 54px); }
.page-head p:not(.eyebrow) { max-width: 720px; margin: 12px 0 0; color: var(--muted); line-height: 1.6; }

.case-list { display: grid; gap: 12px; }
.case-row {
  display: grid;
  grid-template-columns: minmax(170px, 1.1fr) minmax(210px, 1.4fr) 130px 130px auto;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(248, 245, 239, .88);
}
.case-row strong, .case-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.case-row small { display: block; margin-top: 4px; color: var(--muted); }
.case-object { color: var(--muted); }
.case-open { justify-self: end; }
.empty-state { padding: 56px 24px; text-align: center; border: 1px dashed rgba(17,17,17,.18); border-radius: 24px; background: rgba(248,245,239,.46); }
.empty-state h3 { margin: 12px 0 8px; font-size: 26px; }
.empty-state p { max-width: 520px; margin: 0 auto 22px; color: var(--muted); }
.empty-icon { font-size: 38px; }

.panel { min-width: 0; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.form-panel { padding: clamp(24px, 4vw, 38px); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.span-two { grid-column: span 2; }
.panel-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 26px; }

.studio-head { align-items: center; }
.case-id { padding: 8px 12px; border-radius: 999px; background: rgba(17,17,17,.06); color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.studio-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(290px, .75fr); gap: 22px; align-items: start; }
.recorder-panel, .script-panel, .master-card { padding: clamp(22px, 4vw, 34px); }
.panel-title, .panel-title > div, .delivery-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.panel-title > div { justify-content: flex-start; }
.panel-title h3, .finalize-panel h3, .delivery-panel h3, .script-panel h3 { margin: 0; font-size: 25px; letter-spacing: -.03em; }
.step-number { width: 38px; height: 38px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; background: var(--ink); color: #fff; font-weight: 800; }
.step-number.is-good { background: var(--good); }
.status-pill { display: inline-flex; align-items: center; width: max-content; max-width: 100%; padding: 7px 10px; border-radius: 999px; background: rgba(17,17,17,.065); color: var(--muted); font-size: 11px; font-weight: 800; white-space: nowrap; }
.status-pill.status-good { background: var(--good-bg); color: var(--good); }
.status-pill.status-warn { background: var(--warn-bg); color: var(--warn); }
.wave-wrap { position: relative; overflow: hidden; margin: 28px 0 22px; min-height: 190px; border-radius: 20px; background: linear-gradient(145deg, #171410, #090909); }
.wave-wrap-small { min-height: 150px; }
.wave-wrap canvas { display: block; width: 100%; height: 190px; }
.wave-wrap-small canvas { height: 150px; }
.timer { position: absolute; inset: auto 18px 16px auto; padding: 7px 10px; border-radius: 999px; background: rgba(255,255,255,.1); color: #fff; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; backdrop-filter: blur(8px); }
.record-controls { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 12px; }
.record-button { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 50px; padding: 13px 21px; border-radius: 999px; background: var(--ink); color: white; cursor: pointer; font-weight: 800; }
.record-button span { width: 13px; height: 13px; border-radius: 50%; background: #e44b3d; box-shadow: 0 0 0 6px rgba(228,75,61,.14); }
.record-button.is-recording span { animation: recordPulse 1.15s infinite; }
@keyframes recordPulse { 50% { box-shadow: 0 0 0 11px rgba(228,75,61,0); } }
.preview-card { margin-top: 24px; padding: 20px; border-radius: 18px; background: #fff; border: 1px solid var(--line); }
.preview-card > div:first-child { display: grid; gap: 3px; margin-bottom: 13px; }
.preview-card > div:first-child span { color: var(--muted); font-size: 13px; }
audio { width: 100%; min-height: 42px; }
.inline-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.script-panel { position: sticky; top: 106px; }
.script-list { display: grid; gap: 12px; margin: 24px 0; padding: 0; list-style: none; counter-reset: guide; }
.script-list li { counter-increment: guide; position: relative; padding: 12px 12px 12px 44px; border-radius: 13px; background: #fff; color: var(--ink-2); line-height: 1.45; }
.script-list li::before { content: counter(guide); position: absolute; left: 12px; top: 11px; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; background: var(--paper-2); color: var(--muted); font-size: 11px; font-weight: 800; }
.script-note { padding: 16px; border-radius: 15px; background: var(--warn-bg); }
.script-note p { margin: 5px 0 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.finalize-panel { display: flex; align-items: center; justify-content: space-between; gap: 22px; margin-top: 22px; padding: 28px 30px; }
.finalize-panel p:not(.eyebrow) { max-width: 720px; margin: 7px 0 0; color: var(--muted); line-height: 1.55; }
.delivery-panel { margin-top: 22px; padding: clamp(22px, 4vw, 34px); }
.final-audio { margin-top: 22px; }
.delivery-download { margin-top: 10px; }
.mail-editor { display: grid; gap: 16px; margin-top: 28px; padding-top: 26px; border-top: 1px solid var(--line); }

.master-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; align-items: start; }
.sound-design-card { grid-column: 1 / -1; }
.sound-previews { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-top: 20px; }
.sound-previews label { padding: 16px; border-radius: 16px; background: #fff; border: 1px solid var(--line); }
.sound-previews audio { margin-top: 9px; }
.sound-controls { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; margin-top: 20px; padding: 20px; border-radius: 18px; background: #fff; border: 1px solid var(--line); }
.sound-controls label { display: grid; gap: 9px; }
.sound-controls label > span { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; font-weight: 750; }
.sound-controls output { color: var(--gold-dark); }
.sound-controls input[type="range"] { width: 100%; accent-color: var(--ink); }
.master-card > p { color: var(--muted); line-height: 1.55; }
.master-card audio { margin-top: 18px; }
.audio-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 15px; }
.audio-meta span { padding: 7px 10px; border-radius: 999px; background: #fff; color: var(--muted); font-size: 11px; font-weight: 700; }
blockquote { margin: 20px 0; padding: 20px; border-left: 3px solid var(--gold); border-radius: 0 15px 15px 0; background: #fff; color: var(--ink-2); font-size: 15px; line-height: 1.65; }
.current-master { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.current-master > * { margin-top: 13px; }

.toast { position: fixed; z-index: 100; left: 50%; bottom: 26px; transform: translate(-50%, 18px); max-width: min(560px, calc(100vw - 32px)); padding: 13px 17px; border-radius: 999px; background: #111; color: #fff; box-shadow: 0 18px 55px rgba(17,17,17,.24); opacity: 0; pointer-events: none; transition: opacity .22s, transform .22s; font-size: 13px; font-weight: 700; text-align: center; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { background: #8d2f26; }

@media (max-width: 1100px) {
  .app-layout { grid-template-columns: 82px minmax(0, 1fr); }
  .sidebar { padding-inline: 12px; }
  .nav-item { justify-content: center; }
  .nav-item span:last-child, .sidebar-foot { display: none; }
  .studio-grid { grid-template-columns: 1fr; }
  .script-panel { position: static; }
  .master-grid { grid-template-columns: 1fr; }
  .sound-design-card { grid-column: auto; }
  .case-row { grid-template-columns: minmax(160px, 1fr) minmax(200px, 1.2fr) 110px auto; }
  .case-row .case-date { display: none; }
}

@media (max-width: 760px) {
  .topbar { min-height: 70px; padding: 11px 14px; }
  .brand small, #master-badge { display: none; }
  #logout-button { width: 44px; padding: 0; font-size: 0; }
  #logout-button::before { content: "↪"; font-size: 20px; }
  .app-layout { display: block; min-height: calc(100vh - 70px); }
  .sidebar { position: fixed; z-index: 40; inset: auto 12px 12px; width: auto; height: 64px; padding: 8px; border: 1px solid var(--line); border-radius: 20px; background: rgba(248,245,239,.94); box-shadow: 0 18px 45px rgba(39,30,18,.18); backdrop-filter: blur(22px); }
  .sidebar nav { height: 100%; grid-template-columns: repeat(3, 1fr); }
  .nav-item { padding: 8px 14px; }
  .nav-item span:last-child { display: none; }
  .sidebar-foot { display: none; }
  .content { padding: 22px 14px 104px; }
  .hero-panel { min-height: auto; align-items: flex-start; flex-direction: column; padding: 30px 24px; border-radius: 24px; }
  .hero-panel::after { font-size: 100px; }
  .hero-panel h2 { font-size: clamp(40px, 12vw, 60px); }
  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .metric { padding: 17px; }
  .notice, .section-head, .page-head, .finalize-panel { align-items: stretch; flex-direction: column; }
  .form-grid { grid-template-columns: 1fr; }
  .sound-previews { grid-template-columns: 1fr; }
  .sound-controls { grid-template-columns: 1fr; }
  .span-two { grid-column: auto; }
  .panel-actions .button, .finalize-panel .button, .notice .button { width: 100%; }
  .case-row { grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; }
  .case-object { grid-column: 1 / -1; }
  .case-row .case-package, .case-row .case-date { display: none; }
  .case-open { grid-row: 1; grid-column: 2; }
  .studio-head .case-id { align-self: flex-start; }
  .panel-title, .delivery-head { align-items: flex-start; }
  .panel-title > .status-pill { flex: 0 0 auto; }
  .wave-wrap { min-height: 155px; }
  .wave-wrap canvas { height: 155px; }
  .inline-actions .button { flex: 1 1 150px; }
}

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