:root {
  color-scheme: light;
  --ink: #17212b;
  --muted: #5d6a72;
  --line: #d8e1e0;
  --paper: #fbfbf7;
  --panel: #ffffff;
  --mint: #d7f2e3;
  --green: #2c7a4b;
  --coral: #e56b5d;
  --blue: #2f6fae;
  --gold: #dca83c;
  --shadow: 0 18px 50px rgba(34, 46, 54, 0.12);
  --soft-shadow: 0 1px 2px rgba(16, 24, 32, 0.06), 0 24px 70px rgba(31, 44, 51, 0.12);
  --button-shadow: 0 8px 18px rgba(31, 44, 51, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(135deg, rgba(215, 242, 227, 0.72), rgba(255, 255, 255, 0.86) 44%, rgba(229, 107, 93, 0.16)),
    var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.auth-required {
  overflow: hidden;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

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

.app-shell {
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
  min-height: 100vh;
}

.app-shell[aria-hidden="true"] {
  filter: blur(2px);
  pointer-events: none;
  user-select: none;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 20;
  min-height: 100vh;
  padding: 22px;
  display: grid;
  place-items: center;
  background:
    linear-gradient(135deg, rgba(18, 32, 28, 0.78), rgba(23, 33, 43, 0.62)),
    linear-gradient(135deg, rgba(215, 242, 227, 0.94), rgba(255, 255, 255, 0.82) 52%, rgba(229, 107, 93, 0.3));
}

.auth-gate[hidden] {
  display: none;
}

.auth-card {
  width: min(100%, 520px);
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: 8px;
  padding: clamp(22px, 4vw, 34px);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--soft-shadow);
}

.auth-brand {
  color: var(--ink);
  margin-bottom: 28px;
}

.auth-brand small {
  color: var(--muted);
}

.auth-card h1 {
  margin: 0;
  font-size: clamp(2rem, 4.8vw, 4rem);
  line-height: 0.98;
  letter-spacing: 0;
}

.auth-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 28px;
}

.auth-actions button {
  border-radius: 8px;
  padding: 12px 15px;
  background: var(--blue);
  color: #ffffff;
  font-weight: 900;
}

.google-signin-button {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  border: 1px solid #dadce0;
  background: #ffffff !important;
  color: #3c4043 !important;
  box-shadow: 0 1px 2px rgba(60, 64, 67, 0.12);
}

.google-signin-button::before {
  content: "";
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'%3E%3Cpath fill='%234285F4' d='M17.64 9.2c0-.64-.06-1.25-.16-1.84H9v3.48h4.84a4.14 4.14 0 0 1-1.8 2.72v2.26h2.92c1.7-1.57 2.68-3.88 2.68-6.62z'/%3E%3Cpath fill='%2334A853' d='M9 18c2.43 0 4.47-.8 5.96-2.18l-2.92-2.26c-.8.54-1.84.86-3.04.86-2.34 0-4.33-1.58-5.04-3.7H.94v2.33A9 9 0 0 0 9 18z'/%3E%3Cpath fill='%23FBBC05' d='M3.96 10.72A5.4 5.4 0 0 1 3.68 9c0-.6.1-1.18.28-1.72V4.95H.94A9 9 0 0 0 0 9c0 1.45.34 2.82.94 4.05l3.02-2.33z'/%3E%3Cpath fill='%23EA4335' d='M9 3.58c1.32 0 2.5.45 3.43 1.34l2.59-2.58A8.67 8.67 0 0 0 9 0 9 9 0 0 0 .94 4.95l3.02 2.33C4.67 5.16 6.66 3.58 9 3.58z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.auth-actions button:nth-child(2) {
  background: #e8eeec;
  color: var(--ink);
}

.auth-setup {
  margin-top: 18px;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 20px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), transparent 36%),
    #10211c;
  color: #f7fbf6;
  display: flex;
  flex-direction: column;
  gap: 28px;
  box-shadow: inset -1px 0 rgba(255, 255, 255, 0.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: block;
  object-fit: cover;
  flex: 0 0 auto;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.22);
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: #bdd2c8;
  margin-top: 2px;
}

.brand strong {
  font-size: 1.03rem;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-item {
  color: #dcebe5;
  text-decoration: none;
  padding: 12px 13px;
  border-radius: 8px;
  font-weight: 750;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.13);
  color: #ffffff;
  transform: translateX(2px);
}

.storage-card {
  margin-top: auto;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  padding: 15px;
  display: grid;
  grid-template-columns: 12px 1fr;
  gap: 12px;
  background: rgba(255, 255, 255, 0.075);
  backdrop-filter: blur(18px);
}

.storage-card small {
  color: #bfd2c9;
  display: block;
  margin-top: 5px;
  line-height: 1.4;
}

.status-dot {
  width: 10px;
  height: 10px;
  margin-top: 5px;
  border-radius: 999px;
  background: var(--gold);
}

.status-dot.connected {
  background: #69d68a;
}

main {
  min-width: 0;
}

.hero-band {
  min-height: 92vh;
  padding: 56px min(5vw, 76px) 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 82% 18%, rgba(47, 111, 174, 0.16), transparent 28%),
    linear-gradient(135deg, rgba(215, 242, 227, 0.82), rgba(255, 255, 255, 0.74) 48%, rgba(229, 107, 93, 0.14));
}

.hero-copy h1 {
  margin: 0;
  max-width: 760px;
  font-size: clamp(2.35rem, 4.3vw, 5.6rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.hero-copy p:not(.eyebrow) {
  max-width: 620px;
  color: var(--muted);
  line-height: 1.7;
  font-size: 1.05rem;
}

.eyebrow,
.panel-label {
  margin: 0 0 10px;
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.recorder-panel,
.settings-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--soft-shadow);
  backdrop-filter: blur(18px);
}

.recorder-panel {
  padding: clamp(18px, 2.5vw, 28px);
  width: min(100%, 820px);
}

.recorder-topline,
.library-header,
.settings-actions,
.action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.recorder-topline h2,
.library-header h2,
.settings-band h2 {
  margin: 0;
  font-size: clamp(1.45rem, 2vw, 2.2rem);
}

#timer {
  min-width: 96px;
  border-radius: 8px;
  background: #12201c;
  color: #ffffff;
  padding: 11px 13px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  box-shadow: 0 10px 24px rgba(18, 32, 28, 0.2);
}

#waveform {
  width: 100%;
  aspect-ratio: 16 / 5;
  min-height: 150px;
  margin: 20px 0;
  border-radius: 8px;
  background: #17212b;
  display: block;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08), 0 14px 34px rgba(23, 33, 43, 0.12);
}

.controls {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin: 8px 0 20px;
}

.icon-button {
  width: 54px;
  height: 54px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #e8eeec;
  color: var(--ink);
  box-shadow: var(--button-shadow);
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.icon-button:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 26px rgba(31, 44, 51, 0.17);
}

.icon-button:disabled {
  background: #d8dedc;
  color: #8b9693;
  cursor: not-allowed;
  opacity: 0.68;
}

.icon-button.primary {
  background: var(--green);
  color: #ffffff;
}

.icon-button.primary:disabled {
  background: #d8dedc;
  color: #8b9693;
}

.icon-button.danger {
  background: #f7dedb;
  color: #aa362b;
}

.icon {
  display: block;
  width: 22px;
  height: 22px;
  position: relative;
}

.record-icon {
  border-radius: 50%;
  background: currentColor;
}

.pause-icon::before,
.pause-icon::after {
  content: "";
  position: absolute;
  top: 0;
  width: 7px;
  height: 22px;
  border-radius: 2px;
  background: currentColor;
}

.pause-icon::before {
  left: 3px;
}

.pause-icon::after {
  right: 3px;
}

.stop-icon {
  border-radius: 3px;
  background: currentColor;
}

.episode-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: #33424b;
  font-weight: 700;
  font-size: 0.9rem;
}

.wide {
  grid-column: 1 / -1;
}

input,
textarea {
  width: 100%;
  border: 1px solid #dfe8e6;
  border-radius: 8px;
  padding: 12px 13px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.92);
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47, 111, 174, 0.14);
}

textarea {
  resize: vertical;
}

.action-row {
  flex-wrap: wrap;
  margin-top: 16px;
}

.action-row button,
.file-picker,
.settings-actions button {
  border-radius: 8px;
  padding: 12px 15px;
  background: var(--ink);
  color: #ffffff;
  font-weight: 800;
  box-shadow: var(--button-shadow);
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.action-row button:not(:disabled):hover,
.file-picker:hover,
.settings-actions button:not(:disabled):hover,
.editor-actions button:not(:disabled):hover,
.recording-actions button:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(31, 44, 51, 0.15);
}

.download-picker {
  position: relative;
}

.file-picker {
  background: #e8eeec;
  color: var(--ink);
  cursor: pointer;
}

.file-picker input {
  display: none;
}

.download-menu {
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  min-width: 160px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px;
  background: #ffffff;
  box-shadow: var(--shadow);
  z-index: 5;
}

.download-menu[hidden] {
  display: none;
}

.download-menu button {
  width: 100%;
  display: block;
  padding: 9px 10px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.download-menu button:hover {
  background: #e8eeec;
}

#saveDriveButton,
#connectDriveButton {
  background: var(--blue);
}

#previewPlayer {
  width: 100%;
  margin: 0 0 14px;
  display: none;
}

.audio-editor {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(248, 252, 250, 0.94)),
    #fbfdfc;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.72);
}

.audio-editor[hidden] {
  display: none;
}

.editor-head,
.editor-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.editor-head h3 {
  margin: 0;
  font-size: 1.15rem;
}

#editorSelectionLabel {
  border-radius: 8px;
  padding: 9px 11px;
  background: #12201c;
  color: #ffffff;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

#editorWaveform {
  width: 100%;
  aspect-ratio: 16 / 4;
  min-height: 120px;
  margin: 16px 0 12px;
  border-radius: 8px;
  background: #17212b;
  display: block;
  touch-action: none;
  cursor: ew-resize;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08), 0 14px 30px rgba(23, 33, 43, 0.12);
}

.editor-actions {
  justify-content: flex-start;
}

.editor-actions button {
  border-radius: 8px;
  padding: 10px 13px;
  background: #e8eeec;
  color: var(--ink);
  font-weight: 800;
  box-shadow: none;
}

.editor-actions button:nth-child(2) {
  background: var(--green);
  color: #ffffff;
}

.editor-actions button:nth-child(3) {
  background: #f7dedb;
  color: #aa362b;
}

.workspace-grid,
.settings-band {
  padding: 56px min(5vw, 76px);
}

.workspace-grid {
  background: rgba(255, 255, 255, 0.86);
}

.library-header {
  align-items: flex-end;
  margin-bottom: 22px;
}

.recording-list {
  display: grid;
  gap: 14px;
}

.recording-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: center;
  border: 1px solid #e2eae8;
  border-radius: 8px;
  padding: 17px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 1px 2px rgba(16, 24, 32, 0.04);
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.recording-card:hover {
  border-color: #c9d8d5;
  box-shadow: 0 14px 34px rgba(31, 44, 51, 0.08);
  transform: translateY(-1px);
}

.recording-card h3 {
  margin: 0 0 6px;
  font-size: 1.1rem;
}

.recording-summary {
  min-width: 0;
  border-radius: 8px;
  padding: 9px;
  margin: -9px;
  background: transparent;
  color: inherit;
  text-align: left;
}

.recording-summary:hover,
.recording-summary:focus-visible {
  background: #eef5f2;
  outline: none;
}

.recording-meta {
  color: var(--muted);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 0.9rem;
}

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

.recording-actions a,
.recording-actions button {
  border-radius: 8px;
  padding: 9px 12px;
  background: #e8eeec;
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
  font-size: 0.9rem;
  box-shadow: none;
}

.imported-recording {
  border-style: dashed;
  background: linear-gradient(180deg, #ffffff, #fbfdfc);
}

.empty-state {
  border: 1px dashed #aebcba;
  border-radius: 8px;
  padding: 28px;
  color: var(--muted);
  background: #f8faf8;
}

.settings-band p {
  color: var(--muted);
  line-height: 1.7;
  max-width: 680px;
}

.settings-band {
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) minmax(320px, 1fr);
  gap: 34px;
  align-items: start;
  background: rgba(251, 251, 247, 0.92);
}

.settings-panel {
  padding: 20px;
}

.settings-actions {
  justify-content: flex-start;
  flex-wrap: wrap;
  margin-top: 14px;
}

.settings-actions button:nth-child(2) {
  background: #e8eeec;
  color: var(--ink);
}

.account-summary {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 13px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #f8faf8;
}

.account-icon {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #ffffff;
  color: var(--blue);
  border: 1px solid var(--line);
  font-weight: 900;
}

.account-summary strong,
.account-summary small {
  display: block;
}

.account-summary small {
  color: var(--muted);
  line-height: 1.45;
  margin-top: 4px;
}

.setup-warning {
  margin-top: 14px;
  border: 1px solid #ebd39a;
  border-radius: 8px;
  padding: 12px;
  background: #fff8e8;
  color: #6f5012;
  line-height: 1.45;
  font-size: 0.92rem;
}

.setup-warning p {
  margin: 0 0 12px;
  color: inherit;
}

.setup-warning label {
  color: #6f5012;
}

.setup-warning button {
  margin-top: 10px;
  border-radius: 8px;
  padding: 10px 12px;
  background: #6f5012;
  color: #ffffff;
  font-weight: 800;
}

.setup-warning code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 800;
}

.fine-print {
  font-size: 0.88rem;
  margin-bottom: 0;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: min(420px, calc(100vw - 44px));
  padding: 13px 14px;
  border-radius: 8px;
  background: #12201c;
  color: #ffffff;
  box-shadow: var(--shadow);
  transform: translateY(140%);
  transition: transform 180ms ease;
  z-index: 10;
}

.toast.show {
  transform: translateY(0);
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }

  .nav-list {
    display: flex;
    flex-wrap: wrap;
  }

  .storage-card {
    width: 100%;
    margin-top: 0;
  }

  .hero-band,
  .settings-band {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .hero-band,
  .workspace-grid,
  .settings-band {
    padding: 34px 18px;
  }

  .recorder-panel {
    padding: 16px;
  }

  .episode-form {
    grid-template-columns: 1fr;
  }

  .library-header,
  .recorder-topline,
  .recording-card {
    grid-template-columns: 1fr;
    display: grid;
    align-items: start;
  }

  .recording-actions {
    justify-content: flex-start;
  }

  .recording-actions button {
    flex: 1 1 auto;
  }
}
