:root {
  --navy: #003f88;
  --navy-2: #0054a8;
  --blue: #0b58ad;
  --blue-soft: #e9f2ff;
  --green: #178a3d;
  --caise-green: #178a3d;
  --ink: #05183f;
  --muted: #667085;
  --line: #d8e3f2;
  --panel: #ffffff;
  --panel-soft: #f8fbff;
  --bg: #f3f6fb;
  --shadow: 0 18px 40px rgba(12, 43, 89, .08);
  --shadow-soft: 0 8px 18px rgba(12, 43, 89, .07);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 18% -10%, #ffffff 0, #f6f9fe 34%, var(--bg) 100%); }
button, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .56; }

.app-shell { max-width: 1510px; margin: 0 auto; padding: 28px 32px 44px; }
.topbar { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 32px; margin-bottom: 24px; }
.brand-strip { display: flex; align-items: center; gap: 34px; min-width: 420px; }
.logo { display: block; object-fit: contain; }
.logo-caise { width: 132px; height: 55px; }
.logo-admed { width: 255px; height: 79px; max-height: 55px; object-fit: contain; object-position: left center; }
.title-block h1 { margin: 0; color: var(--navy); font-weight: 850; font-size: clamp(28px, 3vw, 42px); letter-spacing: -.03em; line-height: 1.05; }
.title-block p { margin: 8px 0 0; color: #164276; font-size: 18px; }
.top-actions { display: flex; gap: 8px; align-items: center; }
.pill { border: 0; background: transparent; color: #17365f; font-weight: 800; padding: 8px 12px; border-radius: 999px; }
.pill.active { color: #fff; background: var(--navy); }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 28px; align-items: start; }
.workspace { min-width: 0; }
.card, .accordion-card, .side-tile, .status-line { background: rgba(255,255,255,.92); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-soft); }
.card { padding: 24px 28px; margin-bottom: 6px; }
.input-card { margin-bottom: 8px; }
.section-heading { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 18px; }
.section-heading.compact { align-items: center; margin-bottom: 16px; }
.section-heading h2 { margin: 0; color: var(--navy); font-size: 22px; font-weight: 850; }
.section-heading p { margin: 4px 0 0; color: var(--muted); line-height: 1.45; }
.icon { width: 30px; height: 30px; display: inline-grid; place-items: center; border-radius: 10px; color: var(--blue); background: var(--blue-soft); font-weight: 900; flex: 0 0 auto; }
.icon.wave { font-size: 22px; }
.icon.chart { font-size: 18px; }

.input-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 30px; align-items: start; }
.field { display: block; margin: 0; }
.field span { display: block; color: var(--navy); font-weight: 850; margin: 0 0 8px; }
.field small { display: block; color: var(--muted); font-size: 12px; text-align: right; transform: translateY(-28px); padding-right: 14px; pointer-events: none; }
textarea, select { width: 100%; border: 1px solid #cbd8ea; border-radius: 10px; background: #fff; color: var(--ink); padding: 14px 16px; outline: none; box-shadow: inset 0 1px 1px rgba(12,43,89,.03); }
textarea { min-height: 155px; resize: vertical; line-height: 1.55; padding-bottom: 34px; }
textarea:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(11,88,173,.12); }
.control-stack { display: grid; gap: 16px; align-content: start; }
.primary-btn, .secondary-btn { width: 100%; border: 0; border-radius: 10px; padding: 14px 18px; font-weight: 850; transition: transform .15s ease, filter .15s ease, box-shadow .15s ease; }
.primary-btn { color: #fff; background: linear-gradient(135deg, var(--navy), var(--blue)); box-shadow: 0 10px 22px rgba(0,84,168,.22); }
.primary-btn:hover:not(:disabled), .secondary-btn:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(.98); }
.primary-btn.loading span { animation: pulse 1s infinite ease-in-out; }
.secondary-btn { color: var(--navy); background: #eef5ff; border: 1px solid #cbd8ea; }
@keyframes pulse { 0%,100% { opacity: .35; } 50% { opacity: 1; } }

.status-line { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 10px 14px; color: #40506d; margin: 10px 0 6px; }
.status-dot { width: 10px; height: 10px; border-radius: 999px; background: #b8c3d6; box-shadow: 0 0 0 5px rgba(184,195,214,.18); }
.status-dot.ok { background: #10a04a; box-shadow: 0 0 0 5px rgba(16,160,74,.12); }
.status-dot.err { background: #d92d20; box-shadow: 0 0 0 5px rgba(217,45,32,.12); }
.job-summary { margin-left: auto; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 58%; }

.results-card { margin-top: 8px; }
.tts-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; margin-bottom: 26px; }
.tts-card { border: 1px solid var(--line); border-radius: 14px; background: var(--panel-soft); padding: 18px 16px; }
.badge { display: inline-block; color: var(--navy); background: #dcecff; border-radius: 999px; padding: 5px 10px; font-size: 12px; font-weight: 850; margin-bottom: 14px; }
.tts-card h3 { margin: 0 0 14px; font-size: 22px; color: #061a45; }
audio { width: 100%; margin: 8px 0 14px; }
.metric-list { margin: 0; display: grid; gap: 5px; font-size: 14px; }
.metric-list div { display: flex; gap: 6px; }
.metric-list dt { color: #293b5c; font-weight: 500; }
.metric-list dd { margin: 0; font-weight: 800; color: #213150; }
.metric-list dd.ok, .ok-text { color: var(--green); font-weight: 800; }
.metric-list dd.warn { color: #b42318; }
.metrics-title { margin-top: 8px; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
table { min-width: 980px; width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 12px 14px; border-bottom: 1px solid #e3ebf6; text-align: left; white-space: nowrap; }
th { color: #06225b; background: #f1f6fd; font-weight: 850; }
tbody tr:hover { background: #fafcff; }

.accordion-card { margin-top: 20px; overflow: hidden; }
.accordion-head { width: 100%; border: 0; background: transparent; display: flex; align-items: center; justify-content: space-between; gap: 16px; text-align: left; padding: 16px 20px; color: var(--navy); }
.accordion-head small { color: #53657e; font-weight: 500; }
.chevron { font-size: 28px; transition: transform .15s ease; }
.accordion-head[aria-expanded="true"] .chevron { transform: rotate(90deg); }
.job-info { margin: 0; padding: 18px 20px; background: #07152f; color: #d8e8ff; overflow: auto; max-height: 360px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12px; }

.sidebar { display: grid; gap: 18px; position: sticky; top: 24px; }
.side-tile { width: 100%; min-height: 128px; display: grid; grid-template-columns: 46px minmax(0,1fr) 20px; gap: 14px; align-items: start; border: 1px solid var(--line); padding: 22px 20px; text-align: left; color: var(--ink); background: rgba(255,255,255,.95); transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease; }
.side-tile:hover:not(.muted) { transform: translateY(-1px); border-color: #bcd1ec; box-shadow: var(--shadow); }
.tile-icon { width: 36px; height: 36px; border-radius: 14px; display: grid; place-items: center; color: var(--blue); background: var(--blue-soft); font-size: 21px; font-weight: 900; }
.side-tile b { display: block; color: var(--navy); font-size: 17px; line-height: 1.35; margin-bottom: 12px; }
.side-tile small { display: block; color: #667085; font-size: 14px; line-height: 1.55; }
.arrow { color: var(--navy); font-size: 30px; line-height: 1; }
.side-tile.muted { opacity: .72; }
.info-tile { cursor: default; }

.samples-toggle[aria-expanded="true"] .arrow { transform: rotate(90deg); }
.samples-panel {
  margin-top: -10px;
  padding: 12px;
  border: 1px solid #d8e3f2;
  border-radius: 14px;
  background: rgba(255,255,255,.86);
  box-shadow: var(--shadow-soft);
  display: grid;
  gap: 10px;
}
.samples-panel[hidden] { display: none; }
.samples-hint {
  margin: 2px 2px 4px;
  color: #667085;
  font-size: 13px;
  line-height: 1.45;
}
.sample-option {
  width: 100%;
  border: 1px solid #d7e6f7;
  border-radius: 12px;
  background: linear-gradient(180deg, #fff, #f7fbff);
  padding: 12px 14px;
  text-align: left;
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.sample-option:hover {
  transform: translateY(-1px);
  border-color: #b8d2ef;
  box-shadow: 0 8px 18px rgba(12,43,89,.07);
}
.sample-option b {
  display: block;
  color: var(--navy);
  font-size: 14px;
  margin-bottom: 4px;
}
.sample-option small {
  display: block;
  color: #667085;
  font-size: 12px;
  line-height: 1.35;
}


@media (max-width: 1200px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .app-shell { padding: 20px 16px 32px; }
  .topbar { grid-template-columns: 1fr; gap: 18px; }
  .brand-strip { min-width: 0; flex-wrap: wrap; gap: 16px; }
  .input-grid { grid-template-columns: 1fr; }
  .tts-cards, .sidebar { grid-template-columns: 1fr; }
  .job-summary { display: none; }
}

.app-footer {
  max-width: 1510px;
  margin: 18px auto 0;
  padding: 14px 18px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  color: #617086;
  font-size: 12px;
}
.app-footer strong { color: var(--navy); font-weight: 850; }
.footer-separator { color: #a4b3c7; }

.engine-ribbon {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: -4px 0 20px;
}
.engine-pill {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid #cfe0f7;
  border-radius: 12px;
  padding: 12px 14px;
  background: linear-gradient(180deg, #ffffff, #f3f8ff);
  color: var(--ink);
}
.engine-pill b { color: var(--caise-green, var(--green)); font-size: 16px; white-space: nowrap; font-weight: 900; }
.engine-pill small { color: #366187; font-size: 13px; font-weight: 800; text-align: left; white-space: nowrap; }

.url-hint {
  border: 1px dashed #b6cce9;
  border-radius: 10px;
  padding: 11px 13px;
  background: #f8fbff;
  color: #40506d;
}
.url-hint b { display: block; color: var(--navy); font-size: 13px; margin-bottom: 4px; }
.url-hint small { display: block; font-size: 12px; line-height: 1.45; }

.badge.real-badge {
  color: #12783a;
  background: #e8f7ee;
}
.badge.demo-badge {
  color: #8a4b00;
  background: #fff3d6;
}

body.popup-mode .topbar,
body.popup-mode .sidebar,
body.popup-mode .accordion-card,
body.popup-mode .app-footer { display: none; }
body.popup-mode .app-shell { max-width: 980px; padding: 18px; }
body.popup-mode .layout { grid-template-columns: 1fr; }
body.popup-mode .results-card { margin-top: 12px; }



@media (max-width: 900px) {
  .engine-ribbon { grid-template-columns: 1fr; }
  .engine-pill { flex-wrap: wrap; }
  .engine-pill small { white-space: normal; }
  .input-grid { grid-template-columns: 1fr; }
}
