:root {
  color-scheme: light;
  --ink: #15201c;
  --muted: #63706b;
  --subtle: #8b9791;
  --line: #d8dfda;
  --paper: #f5f7f2;
  --surface: #ffffff;
  --surface-soft: #f9faf6;
  --denela: #0f766e;
  --denela-strong: #095a54;
  --blue: #355c9a;
  --amber: #9b641b;
  --rose: #a54b5c;
  --good-bg: #e6f2ed;
  --warn-bg: #fff1d6;
  --shadow: 0 20px 50px rgba(26, 37, 32, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.62), rgba(255, 255, 255, 0)) 0 0 / 100% 220px no-repeat,
    var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
}

button,
select,
textarea {
  font: inherit;
}

button,
select {
  min-height: 40px;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: progress;
  opacity: 0.68;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.shell {
  width: min(1240px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 4px 0 18px;
}

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

.brand-mark {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, 23px);
  grid-template-rows: repeat(2, 23px);
  gap: 4px;
  width: 56px;
  height: 56px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 12px 28px rgba(18, 31, 27, 0.08);
}

.brand-mark::after {
  content: "";
  position: absolute;
  left: 27px;
  top: 9px;
  width: 1px;
  height: 38px;
  background: var(--line);
  transform: rotate(45deg);
}

.brand-mark span {
  display: grid;
  place-items: center;
  border-radius: 6px;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
}

.brand-mark span:nth-child(1) {
  background: var(--blue);
}

.brand-mark span:nth-child(2) {
  background: var(--denela);
}

.brand-mark span:nth-child(3) {
  grid-column: 2;
  background: var(--amber);
}

h1 {
  font-size: 2.15rem;
  line-height: 1;
  letter-spacing: 0;
}

.brand p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.94rem;
}

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  max-width: min(560px, 48vw);
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.8);
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.status.ready .status-dot {
  background: var(--denela);
}

.status.error .status-dot {
  background: var(--rose);
}

.translator {
  display: grid;
  grid-template-columns: minmax(320px, 0.88fr) minmax(420px, 1.12fr);
  gap: 18px;
  align-items: stretch;
}

.input-pane,
.output-pane,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.input-pane,
.output-pane {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.input-pane {
  grid-template-rows: auto auto minmax(260px, 1fr) auto;
}

.output-pane {
  grid-template-rows: auto 1fr;
}

.pane-head,
.panel-head,
.result-head,
.action-row,
.language-map {
  display: flex;
  align-items: center;
}

.pane-head,
.panel-head,
.result-head {
  justify-content: space-between;
  gap: 12px;
}

h2 {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h3 {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.language-map {
  gap: 7px;
  color: var(--subtle);
  font-size: 0.72rem;
  font-weight: 800;
}

.language-map span {
  display: grid;
  place-items: center;
  width: 30px;
  height: 24px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-soft);
}

.language-map i {
  display: block;
  width: 16px;
  height: 1px;
  background: var(--line);
}

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

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface-soft);
  outline: none;
}

select {
  padding: 9px 34px 9px 10px;
}

textarea {
  resize: vertical;
  min-height: 260px;
  padding: 15px;
  line-height: 1.55;
  letter-spacing: 0;
}

select:focus,
textarea:focus {
  border-color: rgba(15, 118, 110, 0.68);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.action-row {
  gap: 10px;
}

.primary-action,
.secondary-action,
.copy-action {
  border-radius: 8px;
  font-weight: 800;
}

.primary-action {
  flex: 1;
  min-height: 46px;
  background: var(--denela);
  color: #fff;
}

.primary-action:hover {
  background: var(--denela-strong);
}

.secondary-action,
.copy-action {
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--muted);
}

.secondary-action {
  min-width: 82px;
}

.secondary-action:hover,
.copy-action:hover {
  color: var(--ink);
  border-color: #c3ccc6;
}

.checkline {
  min-height: 30px;
  max-width: 65%;
  padding: 6px 10px;
  border: 1px solid #cfe5dc;
  border-radius: 8px;
  background: var(--good-bg);
  color: var(--denela-strong);
  font-size: 0.82rem;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.checkline.review {
  border-color: #ecd4a7;
  background: var(--warn-bg);
  color: var(--amber);
}

.checkline.error {
  border-color: #edc5cc;
  background: #fdecef;
  color: var(--rose);
}

.result-stack {
  display: grid;
  align-content: start;
}

.result {
  display: grid;
  gap: 9px;
  padding: 15px 0;
  border-top: 1px solid var(--line);
}

.result:first-child {
  padding-top: 0;
  border-top: 0;
}

.translation {
  min-height: 32px;
  color: var(--ink);
  font-size: 1.08rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.denela-text {
  min-height: 68px;
  color: var(--denela-strong);
  font-size: 1.72rem;
  font-weight: 820;
  line-height: 1.28;
}

.copy-action {
  min-height: 31px;
  padding: 5px 10px;
  font-size: 0.76rem;
}

.details {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
  gap: 18px;
  margin-top: 18px;
}

.panel {
  overflow: hidden;
}

.panel-head {
  min-height: 52px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

#tokenCount {
  color: var(--subtle);
  font-size: 0.82rem;
  font-weight: 760;
}

.table-wrap {
  max-height: 360px;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th,
td {
  padding: 11px 14px;
  border-bottom: 1px solid #edf0ed;
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

td:first-child {
  color: var(--denela-strong);
  font-weight: 850;
}

td:last-child {
  color: var(--muted);
  font-weight: 720;
}

.notes-panel {
  align-self: start;
}

#analysis {
  padding: 15px 16px 4px;
  color: var(--ink);
  line-height: 1.55;
}

#warnings {
  margin: 10px 16px 16px;
  padding-left: 18px;
  color: var(--amber);
  line-height: 1.45;
}

.empty-row td {
  color: var(--subtle);
  font-weight: 500;
}

@media (max-width: 900px) {
  .shell {
    width: min(calc(100% - 20px), 760px);
    padding-top: 14px;
  }

  .app-header,
  .translator,
  .details {
    grid-template-columns: 1fr;
  }

  .app-header {
    display: grid;
  }

  .status {
    max-width: 100%;
    white-space: normal;
  }

  .translator,
  .details {
    display: grid;
  }

  .checkline {
    max-width: 100%;
    white-space: normal;
  }

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

@media (max-width: 560px) {
  .shell {
    width: min(calc(100% - 14px), 540px);
  }

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

  .brand-mark {
    width: 50px;
    height: 50px;
    grid-template-columns: repeat(2, 20px);
    grid-template-rows: repeat(2, 20px);
  }

  h1 {
    font-size: 1.75rem;
  }

  .input-pane,
  .output-pane {
    padding: 14px;
  }

  .pane-head {
    align-items: flex-start;
  }

  .language-map {
    display: none;
  }

  .denela-text {
    font-size: 1.42rem;
  }

  th,
  td {
    padding: 10px;
  }

  .table-wrap {
    max-height: none;
    overflow: visible;
  }

  table,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }

  thead {
    display: none;
  }

  tr {
    padding: 10px 14px;
    border-bottom: 1px solid #edf0ed;
  }

  tr:last-child {
    border-bottom: 0;
  }

  td {
    display: grid;
    grid-template-columns: minmax(82px, 0.38fr) minmax(0, 1fr);
    gap: 10px;
    padding: 5px 0;
    border-bottom: 0;
    overflow-wrap: anywhere;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.7rem;
    font-weight: 850;
    text-transform: uppercase;
  }

  .empty-row td {
    display: block;
  }

  .empty-row td::before {
    content: "";
  }
}
