:root {
  color-scheme: dark;
  --ink: #edf7f4;
  --muted: #8ea29e;
  --dim: #5e716d;
  --line: rgba(115, 255, 221, .18);
  --panel: rgba(10, 18, 20, .9);
  --panel-2: rgba(13, 25, 27, .94);
  --page: #070b0c;
  --field: #071012;
  --accent: #20e2bd;
  --accent-deep: #0d806e;
  --gold: #f0b85b;
  --danger: #ff5f6d;
  --warn: #f0b85b;
  --ok: #38e48d;
  --shadow: rgba(0, 0, 0, .42);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(rgba(32, 226, 189, .055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(32, 226, 189, .04) 1px, transparent 1px),
    radial-gradient(circle at 20% 0%, rgba(240, 184, 91, .08), transparent 28%),
    var(--page);
  background-size: 36px 36px, 36px 36px, auto, auto;
  color: var(--ink);
  font-family: "Segoe UI", Arial, Helvetica, sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    180deg,
    rgba(255, 255, 255, .025) 0,
    rgba(255, 255, 255, .025) 1px,
    transparent 1px,
    transparent 5px
  );
  mix-blend-mode: screen;
  opacity: .35;
}

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

.shell {
  width: min(1280px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 22px 0 36px;
}

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

.topbar {
  min-height: 86px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(7, 13, 15, .82);
  box-shadow: 0 18px 44px var(--shadow), inset 0 1px 0 rgba(255, 255, 255, .05);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(32, 226, 189, .65);
  border-radius: 8px;
  background: #071113;
  color: var(--accent);
  font-weight: 900;
  box-shadow: inset 0 0 18px rgba(32, 226, 189, .14), 0 0 18px rgba(32, 226, 189, .12);
}

.eyebrow,
.panel-kicker {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(30px, 4vw, 48px);
  line-height: .98;
  letter-spacing: 0;
  text-shadow: 0 0 22px rgba(32, 226, 189, .13);
}

h2 {
  font-size: 16px;
  letter-spacing: .01em;
}

.top-status {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.top-status span {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(240, 184, 91, .32);
  border-radius: 6px;
  padding: 0 11px;
  background: rgba(240, 184, 91, .08);
  color: #f7d9a5;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.formatter {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
}

.panel,
.reference {
  position: relative;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 44px var(--shadow), inset 0 1px 0 rgba(255, 255, 255, .05);
}

.panel::before,
.reference::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), var(--gold), transparent);
  opacity: .85;
}

.panel {
  min-height: 460px;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.panel-title,
.ref-head {
  min-height: 66px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .025);
}

textarea,
.result {
  width: 100%;
  min-height: 300px;
  border: 0;
  padding: 18px;
  resize: none;
  line-height: 1.62;
  background:
    linear-gradient(rgba(255, 255, 255, .018) 1px, transparent 1px),
    var(--field);
  background-size: 100% 32px;
  color: var(--ink);
  font-size: 15px;
}

textarea::placeholder,
input::placeholder {
  color: var(--dim);
}

textarea:focus,
input:focus,
select:focus,
button:focus {
  outline: 2px solid rgba(32, 226, 189, .48);
  outline-offset: 2px;
}

.result {
  display: block;
  white-space: pre-wrap;
}

.controls {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 12px;
  padding: 14px;
  border-top: 1px solid var(--line);
  background: var(--panel-2);
}

.api-key {
  flex: 1;
  min-width: 190px;
}

.actions {
  display: flex;
  gap: 8px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

select,
input {
  min-height: 40px;
  border: 1px solid rgba(142, 162, 158, .32);
  border-radius: 6px;
  padding: 0 11px;
  background: #071012;
  color: var(--ink);
}

button {
  min-height: 40px;
  border: 1px solid rgba(32, 226, 189, .58);
  border-radius: 6px;
  padding: 0 15px;
  background: #0d806e;
  color: #ecfffb;
  cursor: pointer;
  font-weight: 850;
  letter-spacing: .01em;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .03) inset, 0 10px 24px rgba(0, 0, 0, .25);
}

button:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
  background: #119982;
}

button:active {
  transform: translateY(0);
}

#formatBtn {
  background: var(--accent);
  color: #061111;
}

#clearBtn,
#copyBtn,
#aiFormatBtn {
  background: rgba(255, 255, 255, .045);
  color: var(--ink);
  border-color: rgba(142, 162, 158, .34);
}

#aiFormatBtn {
  color: #f7d9a5;
  border-color: rgba(240, 184, 91, .45);
}

button:disabled {
  cursor: wait;
  opacity: .62;
  transform: none;
}

.verdict {
  min-height: 96px;
  display: grid;
  gap: 8px;
  padding: 14px;
  border-top: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  font-size: 13px;
}

.tag {
  display: inline-flex;
  width: fit-content;
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.tag.ok {
  color: #062014;
  background: var(--ok);
}

.tag.warn {
  color: #251604;
  background: var(--warn);
}

.tag.danger {
  color: #2b0308;
  background: var(--danger);
}

.ref-head input {
  width: min(340px, 45vw);
}

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

.rule {
  min-height: 150px;
  padding: 16px;
  border-top: 1px solid var(--line);
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, .015);
}

.rule:nth-child(3n) {
  border-right: 0;
}

.rule h3 {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 14px;
}

.rule p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.developer-credit {
  padding: 2px 4px 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-align: right;
}

.developer-credit a {
  color: var(--accent);
  text-decoration: none;
}

.developer-credit a:hover {
  text-decoration: underline;
}

@media (max-width: 980px) {
  .topbar,
  .formatter {
    grid-template-columns: 1fr;
    display: grid;
  }

  .top-status {
    justify-content: flex-start;
  }

  .rule-list {
    grid-template-columns: 1fr;
  }

  .rule,
  .rule:nth-child(3n) {
    border-right: 0;
  }
}

@media (max-width: 720px) {
  .shell {
    width: min(100% - 18px, 1280px);
    padding-top: 10px;
  }

  .topbar {
    padding: 12px;
  }

  .brand-block {
    align-items: flex-start;
  }

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

  .controls,
  .actions {
    align-items: stretch;
    flex-direction: column;
  }

  .panel-title,
  .ref-head {
    align-items: stretch;
    flex-direction: column;
  }

  .ref-head input {
    width: 100%;
  }
}
