:root {
  --ink: #14211e;
  --muted: #66746f;
  --line: #d8e0db;
  --paper: #fbfcf8;
  --panel: #ffffff;
  --field: #f5f8f4;
  --green: #12624f;
  --green-strong: #0d493b;
  --coral: #c9503d;
  --brass: #b07922;
  --blue: #285b84;
  --shadow: 0 22px 70px rgba(20, 33, 30, 0.12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: "Manrope", system-ui, sans-serif;
  background:
    radial-gradient(circle at 12% 18%, rgba(201, 80, 61, 0.16), transparent 26%),
    radial-gradient(circle at 78% 4%, rgba(40, 91, 132, 0.14), transparent 24%),
    linear-gradient(135deg, #eef5ec 0%, #f9fbf6 46%, #eef3f5 100%);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  opacity: 0.22;
  background-image:
    linear-gradient(rgba(20, 33, 30, 0.1) 1px, transparent 1px),
    linear-gradient(90deg, rgba(20, 33, 30, 0.1) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, black, transparent 72%);
}

button,
textarea,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  width: min(1440px, calc(100vw - 32px));
  min-height: calc(100vh - 32px);
  margin: 16px auto;
  overflow: hidden;
  border: 1px solid rgba(20, 33, 30, 0.12);
  border-radius: var(--radius);
  background: rgba(251, 252, 248, 0.82);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.topbar,
.toolbar,
.statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 22px;
}

.topbar {
  border-bottom: 1px solid var(--line);
}

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

.brand-mark {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 1px solid rgba(18, 98, 79, 0.24);
  border-radius: var(--radius);
  color: var(--paper);
  font-weight: 800;
  letter-spacing: 0;
  background:
    linear-gradient(145deg, rgba(18, 98, 79, 0.96), rgba(40, 91, 132, 0.9)),
    var(--green);
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--coral);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

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

h1 {
  font-family: "Instrument Serif", Georgia, serif;
  font-size: clamp(2.1rem, 4vw, 3.6rem);
  font-weight: 400;
  line-height: 0.9;
}

h2 {
  font-size: 1rem;
  font-weight: 800;
}

.top-actions,
.panel-actions,
.switch-row,
.output-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-button,
.square-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: var(--radius);
  transition: transform 150ms ease, background 150ms ease, border-color 150ms ease;
}

.icon-button {
  gap: 8px;
  min-height: 42px;
  padding: 0 16px;
  font-weight: 800;
}

.icon-button svg,
.square-button svg {
  width: 18px;
  height: 18px;
}

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

.icon-button.primary:hover {
  background: var(--green-strong);
}

.icon-button.ghost,
.square-button {
  color: var(--ink);
  border-color: rgba(20, 33, 30, 0.13);
  background: rgba(255, 255, 255, 0.72);
}

.icon-button:hover,
.square-button:hover {
  transform: translateY(-1px);
}

.square-button {
  width: 38px;
  height: 38px;
}

.copy-primary {
  color: white;
  border-color: rgba(0, 47, 255, 0.28);
  background: #002fff;
}

.copy-primary:hover {
  background: #0026cc;
}

.toolbar {
  flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.42);
}

.linkbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 18px;
  align-items: end;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(90deg, rgba(18, 98, 79, 0.08), transparent 45%),
    rgba(255, 255, 255, 0.52);
}

.link-field {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.link-field label {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.url-wrap {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 42px;
  padding: 0 6px 0 14px;
  border: 1px solid rgba(20, 33, 30, 0.13);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.82);
}

.url-wrap svg {
  width: 18px;
  height: 18px;
  color: var(--blue);
}

.url-wrap input {
  width: 100%;
  min-width: 0;
  color: var(--ink);
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 0.92rem;
  font-weight: 700;
}

.url-wrap input::placeholder {
  color: #8a9692;
}

.output-group {
  justify-content: flex-end;
}

.output-segmented {
  min-width: min(360px, calc(100vw - 64px));
}

.control-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.control-label {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  min-width: min(440px, calc(100vw - 64px));
  overflow: hidden;
  border: 1px solid rgba(20, 33, 30, 0.13);
  border-radius: var(--radius);
  background: #eef4ef;
}

.segmented label {
  position: relative;
  min-width: 0;
}

.segmented input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.segmented span {
  display: grid;
  min-height: 38px;
  place-items: center;
  padding: 0 12px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-align: center;
  white-space: nowrap;
}

.segmented input:checked + span {
  color: white;
  background: var(--blue);
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  color: var(--ink);
  font-size: 0.82rem;
  white-space: nowrap;
}

.switch input {
  position: absolute;
  opacity: 0;
}

.switch span {
  position: relative;
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: #d5ded8;
  transition: background 160ms ease;
}

.switch span::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  content: "";
  background: white;
  box-shadow: 0 2px 8px rgba(20, 33, 30, 0.2);
  transition: transform 160ms ease;
}

.switch input:checked + span {
  background: var(--green);
}

.switch input:checked + span::after {
  transform: translateX(18px);
}

.switch strong {
  font-weight: 800;
}

.compact-switch {
  font-size: 0.78rem;
}

.compact-switch span {
  width: 36px;
  height: 20px;
}

.compact-switch span::after {
  width: 14px;
  height: 14px;
}

.compact-switch input:checked + span::after {
  transform: translateX(16px);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  min-height: 0;
}

.editor-panel {
  display: grid;
  grid-template-rows: auto minmax(360px, 1fr);
  min-width: 0;
  min-height: 0;
  background: rgba(255, 255, 255, 0.68);
}

.input-panel {
  border-right: 1px solid var(--line);
}

.output-panel {
  background:
    linear-gradient(135deg, rgba(18, 98, 79, 0.06), transparent 35%),
    rgba(255, 255, 255, 0.78);
}

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

textarea {
  width: 100%;
  min-width: 0;
  height: 100%;
  min-height: 360px;
  padding: 22px;
  resize: none;
  color: var(--ink);
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.72;
}

textarea[hidden] {
  display: none;
}

textarea::placeholder {
  color: #8a9692;
}

textarea:focus {
  box-shadow: inset 0 0 0 2px rgba(18, 98, 79, 0.2);
}

#outputText {
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(18, 98, 79, 0.04) 0,
      rgba(18, 98, 79, 0.04) 1px,
      transparent 1px,
      transparent 32px
    );
}

.html-preview {
  width: 100%;
  min-width: 0;
  height: 100%;
  min-height: 360px;
  padding: 22px;
  overflow: auto;
  color: var(--ink);
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(18, 98, 79, 0.04) 0,
      rgba(18, 98, 79, 0.04) 1px,
      transparent 1px,
      transparent 32px
    );
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.72;
  white-space: normal;
}

.html-preview[hidden] {
  display: none;
}

.html-preview a {
  color: #002fff !important;
  font-weight: 700;
  text-decoration: underline !important;
  -webkit-text-fill-color: #002fff;
}

.html-preview a * {
  color: #002fff !important;
  text-decoration: underline !important;
  -webkit-text-fill-color: #002fff;
}

.html-preview strong {
  font-weight: 800;
}

.statusbar {
  border-top: 1px solid var(--line);
  background: rgba(20, 33, 30, 0.04);
}

.stat {
  display: grid;
  gap: 2px;
  padding-right: 18px;
  border-right: 1px solid rgba(20, 33, 30, 0.11);
}

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

.stat strong {
  font-size: 0.96rem;
}

#statusText {
  margin: 0 0 0 auto;
  color: var(--green);
  font-size: 0.9rem;
  font-weight: 800;
}

button:focus-visible,
input:focus-visible + span,
textarea:focus-visible,
.url-wrap:focus-within {
  outline: 3px solid rgba(176, 121, 34, 0.42);
  outline-offset: 2px;
}

@media (max-width: 980px) {
  .app-shell {
    width: min(100vw - 20px, 760px);
    min-height: calc(100vh - 20px);
    margin: 10px auto;
  }

  .topbar,
  .toolbar,
  .linkbar,
  .statusbar {
    align-items: stretch;
    flex-direction: column;
  }

  .linkbar {
    display: flex;
  }

  .topbar {
    align-items: center;
    flex-direction: row;
  }

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

  .input-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .editor-panel {
    grid-template-rows: auto minmax(280px, 42vh);
  }

  textarea {
    min-height: 280px;
  }

  .control-group,
  .link-field,
  .switch-row {
    width: 100%;
  }

  .output-group {
    justify-content: stretch;
  }

  .switch-row {
    flex-wrap: wrap;
  }

  #statusText {
    margin: 0;
  }
}

@media (max-width: 620px) {
  body {
    background: linear-gradient(145deg, #eef5ec 0%, #f9fbf6 100%);
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .icon-button {
    width: 100%;
  }

  .brand-mark {
    width: 42px;
    height: 42px;
  }

  .segmented {
    min-width: 100%;
  }

  .url-wrap {
    grid-template-columns: auto minmax(0, 1fr) 38px;
  }

  .segmented span {
    padding-inline: 8px;
    font-size: 0.76rem;
  }

  .panel-head {
    min-height: 68px;
  }

  .output-panel .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  textarea {
    padding: 18px;
    font-size: 0.95rem;
  }

  .statusbar {
    display: grid;
    grid-template-columns: 1fr;
  }

  .stat {
    padding: 0 0 10px;
    border-right: 0;
    border-bottom: 1px solid rgba(20, 33, 30, 0.11);
  }
}
