:root {
  color-scheme: light;
  --bg: #f5f7f9;
  --panel: #ffffff;
  --panel-strong: #eef4f2;
  --text: #172026;
  --muted: #61707a;
  --line: #d7dee3;
  --blue: #235fbd;
  --green: #167a53;
  --amber: #a25d00;
  --red: #b42318;
  --shadow: 0 12px 30px rgba(23, 32, 38, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  letter-spacing: 0;
}

button,
input,
textarea {
  font: inherit;
}

.shell {
  min-height: 100vh;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  max-width: 1380px;
  margin: 0 auto 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
}

h1,
h2 {
  margin: 0;
  line-height: 1.1;
}

h1 {
  font-size: 30px;
  font-weight: 750;
}

h2 {
  font-size: 17px;
}

.status-strip {
  min-width: 190px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  text-align: center;
}

.status-strip.ready {
  color: var(--green);
  border-color: rgba(22, 122, 83, 0.35);
  background: #edf8f3;
}

.status-strip.warn {
  color: var(--amber);
  border-color: rgba(162, 93, 0, 0.35);
  background: #fff7e8;
}

.status-strip.error {
  color: var(--red);
  border-color: rgba(180, 35, 24, 0.35);
  background: #fff1ef;
}

.layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 18px;
  max-width: 1380px;
  margin: 0 auto;
}

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

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-self: start;
  padding: 16px;
}

.metric {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.metric span,
.label,
.field span {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  font-size: 14px;
}

.workspace {
  display: grid;
  gap: 14px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tab,
.segment {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}

.tab {
  padding: 0 16px;
}

.tab.active,
.segment.active {
  border-color: var(--blue);
  background: #edf4ff;
  color: var(--blue);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.form-grid {
  display: grid;
  grid-template-columns: minmax(300px, 0.85fr) minmax(360px, 1.15fr);
  gap: 14px;
}

.tool-panel {
  padding: 16px;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

.field.compact {
  margin-bottom: 0;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--text);
  outline: none;
}

input {
  min-height: 42px;
  padding: 0 11px;
}

textarea {
  min-height: 180px;
  padding: 10px 11px;
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(35, 95, 189, 0.12);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.segment {
  padding: 0 8px;
}

.preview {
  display: grid;
  place-items: center;
  min-height: 220px;
  max-height: 360px;
  overflow: hidden;
  border: 1px dashed #b8c4cc;
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--muted);
}

.preview img,
.preview video {
  width: 100%;
  height: 100%;
  max-height: 360px;
  object-fit: contain;
  background: #11181c;
}

.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.switch-row {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: center;
  min-height: 42px;
}

.switch-row label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.switch-row input {
  width: 18px;
  min-height: 18px;
}

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

.button {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 14px;
  cursor: pointer;
}

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

.button.secondary {
  border-color: var(--line);
  background: #ffffff;
  color: var(--text);
}

.button.ghost {
  background: transparent;
  color: var(--muted);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.session-grid {
  display: grid;
  gap: 14px;
}

.auth-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.auth-summary > div,
.auth-flags span {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 12px;
}

.auth-summary strong {
  display: block;
  margin-top: 4px;
}

.auth-flags {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.auth-flags span {
  color: var(--muted);
  font-size: 13px;
}

code,
pre {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

code {
  display: block;
  overflow-x: auto;
  padding: 10px;
  border-radius: 8px;
  background: #f1f4f6;
  color: #25313a;
}

.result-panel {
  min-height: 260px;
}

.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

pre {
  min-height: 210px;
  max-height: 420px;
  margin: 0;
  padding: 16px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 980px) {
  .shell {
    padding: 14px;
  }

  .topbar,
  .layout,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .layout {
    display: grid;
  }

  .topbar {
    display: grid;
    align-items: start;
  }
}

@media (max-width: 640px) {
  .two-col,
  .segmented,
  .auth-summary,
  .auth-flags {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 24px;
  }

  .button,
  .tab {
    width: 100%;
  }
}
