:root {
  --ink: #17202a;
  --muted: #667085;
  --line: #d7dde5;
  --panel: #ffffff;
  --page: #f4f7f8;
  --sidebar: #12263a;
  --sidebar-soft: #1d3b57;
  --navy: #17324d;
  --teal: #0f766e;
  --amber: #b86b00;
  --danger: #b42318;
  --soft-teal: #e6f4f1;
  --soft-amber: #fff3dc;
  --shadow: 0 18px 45px rgba(23, 32, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--page);
  font-family: Arial, Helvetica, sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 16px;
  cursor: pointer;
  font-weight: 700;
}

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

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
  background: var(--sidebar);
  color: #fff;
  padding: 22px 18px;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 8px;
  background: #fff;
  color: var(--sidebar);
  font-weight: 800;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 20px;
  line-height: 1.1;
}

h2 {
  font-size: 28px;
  line-height: 1.15;
}

h3 {
  font-size: 18px;
  line-height: 1.2;
}

.brand-block p,
.page-header p,
.preview-header p,
.message-area,
.result-label,
.tool-card p,
.session-box {
  color: var(--muted);
  font-size: 14px;
}

.brand-block p,
.session-box {
  color: #c9d6e2;
}

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

.nav-button {
  width: 100%;
  justify-content: flex-start;
  border-color: transparent;
  background: transparent;
  color: #dce7f1;
  text-align: left;
}

.nav-button.active,
.nav-button:hover {
  background: var(--sidebar-soft);
  color: #fff;
}

.session-box {
  margin-top: auto;
  display: grid;
  gap: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.18);
  padding-top: 18px;
}

.session-box a,
.primary-link {
  color: #fff;
  font-weight: 700;
  text-decoration: none;
}

.disabled-link {
  pointer-events: none;
  opacity: 0.75;
}

.main-area {
  min-width: 0;
  padding: 28px;
}

.view,
.locked-view {
  max-width: 1320px;
  margin: 0 auto;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 20px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-pill {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 16px;
}

.tool-card {
  position: relative;
  overflow: hidden;
  display: grid;
  gap: 14px;
  min-height: 210px;
  align-content: start;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 20px;
}

.tool-card button {
  align-self: end;
  justify-self: start;
  margin-top: 8px;
}

.tool-accent {
  width: 44px;
  height: 5px;
  border-radius: 999px;
}

.tool-accent.teal {
  background: var(--teal);
}

.tool-accent.amber {
  background: var(--amber);
}

.tool-accent.navy {
  background: var(--navy);
}

.locked-panel {
  max-width: 520px;
  margin: 12vh auto 0;
  display: grid;
  gap: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.locked-panel .primary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: max-content;
  min-height: 42px;
  border-radius: 6px;
  background: var(--teal);
  padding: 0 16px;
}

.panels {
  display: grid;
  grid-template-columns: minmax(360px, 0.82fr) minmax(420px, 1fr);
  gap: 18px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.input-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 700px;
  padding: 18px;
}

.output-panel {
  display: flex;
  flex-direction: column;
  min-height: 700px;
  padding: 18px;
}

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

.field-row {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.field-row.grow {
  flex: 1;
  min-height: 340px;
}

label {
  color: #344054;
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

input,
select {
  min-height: 42px;
  padding: 8px 10px;
}

input[type="file"] {
  padding: 9px 10px;
}

textarea {
  min-height: 100%;
  resize: vertical;
  padding: 12px;
  line-height: 1.48;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.16);
}

.button-row {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.primary {
  background: var(--teal);
  color: #fff;
}

.secondary {
  border-color: var(--line);
  background: #fff;
  color: var(--navy);
}

.compact {
  min-height: 34px;
}

.preview-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 12px;
}

#scriptPreview {
  flex: 1;
  min-height: 470px;
  background: #fbfcfd;
}

.result {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  margin-top: 14px;
  border: 1px solid #b9dfd7;
  border-radius: 8px;
  background: var(--soft-teal);
  padding: 14px;
}

.result a {
  display: inline-block;
  margin-top: 4px;
  color: #075e58;
  font-weight: 700;
  overflow-wrap: anywhere;
}

audio {
  width: 100%;
}

.message-area {
  min-height: 42px;
  margin-top: 16px;
}

.message {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: #fff;
}

.message.success {
  border-color: #b9dfd7;
  background: var(--soft-teal);
  color: #075e58;
}

.message.warning {
  border-color: #ffd596;
  background: var(--soft-amber);
  color: #7a4500;
}

.message.error {
  border-color: #f5b6ae;
  background: #fff1f0;
  color: var(--danger);
}

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 2;
    display: grid;
    grid-template-columns: minmax(210px, 1fr) auto;
    align-items: center;
  }

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

  .session-box {
    margin-top: 0;
    border-top: 0;
    padding-top: 0;
    justify-items: end;
  }

  .tool-grid,
  .panels {
    grid-template-columns: 1fr;
  }

  .input-panel,
  .output-panel {
    min-height: auto;
  }

  .field-row.grow,
  #sourceText,
  #scriptPreview {
    min-height: 320px;
  }
}

@media (max-width: 640px) {
  .main-area {
    padding: 18px;
  }

  .sidebar {
    padding: 16px;
  }

  .page-header,
  .header-actions,
  .button-row {
    align-items: stretch;
    flex-direction: column;
  }

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