:root {
  color-scheme: light;
  --bg: #f4f7f8;
  --ink: #172026;
  --muted: #637178;
  --panel: #ffffff;
  --line: #d8e1e5;
  --accent: #0f766e;
  --accent-dark: #0b5d57;
  --warning: #a13d2d;
  --code-bg: #101820;
  --code-fg: #e7f0f2;
  --soft-blue: #e8f1fb;
  --soft-green: #e6f3ef;
  --shadow: 0 20px 50px rgba(23, 32, 38, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  overflow: hidden;
}

body {
  height: 100%;
  min-height: 100dvh;
  margin: 0;
  background:
    linear-gradient(135deg, rgba(232, 241, 251, 0.9), transparent 34%),
    linear-gradient(315deg, rgba(230, 243, 239, 0.8), transparent 38%),
    var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  overflow: hidden;
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

button:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

button:active {
  transform: translateY(1px);
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.24);
  outline-offset: 2px;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  height: 100dvh;
  margin: 0 auto;
  padding: clamp(10px, 2dvh, 18px) 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: clamp(8px, 1.4dvh, 14px);
  overflow: hidden;
}

.intro {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0;
}

.generator-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  overflow: hidden;
}

.generator-nav a {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 11px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 800;
  text-decoration: none;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease;
}

.generator-nav a:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.generator-nav a[aria-current="page"] {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-dark);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  max-width: 760px;
  font-size: clamp(1.35rem, 3vw, 2.25rem);
  line-height: 1.05;
}

h2 {
  font-size: 0.92rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid rgba(15, 118, 110, 0.24);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--accent-dark);
  font-size: 0.82rem;
  font-weight: 800;
  white-space: nowrap;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(300px, 410px) minmax(0, 1fr);
  gap: 20px;
  align-items: stretch;
  min-height: 0;
  overflow: hidden;
}

.builder,
.output-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.builder {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 14px;
  overflow: auto;
}

.field-label {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 118px;
  gap: 10px;
}

input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 13px;
  background: #fbfdfd;
  color: var(--ink);
  font-family:
    "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.86rem;
}

input.invalid {
  border-color: var(--warning);
}

.primary-action {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.primary-action:hover {
  background: var(--accent-dark);
  color: #ffffff;
}

.error-text {
  min-height: 0;
  margin: 3px 0 0;
  color: var(--warning);
  font-size: 0.78rem;
  font-weight: 700;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 10px 0;
}

.field-block {
  display: grid;
  gap: 5px;
}

.field-block .field-label {
  margin-bottom: 0;
}

.field-error {
  min-height: 0;
  margin: 0;
}

.converter-block {
  display: grid;
  gap: 7px;
  margin: 0 0 12px;
}

.converter-block .field-label {
  margin-bottom: 0;
}

.helper-text {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.3;
}

.host-readout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  grid-column: 1 / -1;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  background: linear-gradient(90deg, var(--soft-blue), var(--soft-green));
}

.host-readout span {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
}

.host-readout strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-family:
    "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.78rem;
}

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

.actions button,
.converter-block button {
  padding: 0 8px;
  font-size: 0.76rem;
  line-height: 1.15;
  white-space: normal;
}

.output-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.output-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 44px;
  border-bottom: 1px solid var(--line);
  padding: 0 18px;
}

.output-header span {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--accent-dark);
  font-family:
    "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.88rem;
  font-weight: 800;
}

textarea {
  width: 100%;
  min-height: 0;
  flex: 1;
  resize: none;
  border: 0;
  padding: 14px;
  background: var(--code-bg);
  color: var(--code-fg);
  font-family:
    "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.78rem;
  line-height: 1.45;
  overflow: auto;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.old-tag-input {
  min-height: 86px;
  flex: initial;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfdfd;
  color: var(--ink);
  font-size: 0.74rem;
  line-height: 1.35;
  white-space: pre-wrap;
}

.taboola-old-tag-input {
  min-height: 220px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 10;
  max-width: min(360px, calc(100vw - 40px));
  border-radius: 8px;
  padding: 13px 15px;
  background: var(--ink);
  color: #ffffff;
  font-size: 0.92rem;
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 820px) {
  .app-shell {
    width: min(100% - 24px, 680px);
    padding: 8px 0;
    gap: 8px;
  }

  .intro {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
    padding: 0;
  }

  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
    gap: 10px;
  }

  .builder,
  .output-panel {
    min-height: 0;
  }

  .output-panel {
    height: auto;
  }
}

@media (max-width: 520px) {
  .status-pill {
    display: none;
  }

  h1 {
    font-size: 1.25rem;
  }

  .generator-nav {
    gap: 6px;
  }

  .generator-nav a {
    min-height: 30px;
    padding: 5px 8px;
    font-size: 0.78rem;
  }

  .input-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

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

  .actions {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .output-header {
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
    padding: 12px 14px;
  }

  textarea {
    padding: 10px;
    font-size: 0.72rem;
  }

  .old-tag-input {
    min-height: 70px;
  }

  .taboola-old-tag-input {
    min-height: 120px;
  }
}
