:root {
  color-scheme: light;
  --bg: #f5f7f6;
  --surface: #ffffff;
  --surface-2: #eef3f1;
  --line: #d7dfdc;
  --text: #18201d;
  --muted: #65736d;
  --accent: #0f766e;
  --accent-dark: #0b5f59;
  --danger: #b42318;
  --shadow: 0 8px 30px rgba(24, 32, 29, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

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

button {
  min-height: 36px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 0 14px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
}

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

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

button.ghost:hover {
  background: var(--surface-2);
}

input,
select,
textarea {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 9px;
  background: #fff;
  color: var(--text);
}

textarea {
  resize: vertical;
}

label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

label input,
label select,
label textarea {
  color: var(--text);
  font-size: 14px;
  font-weight: 400;
}

.input-with-button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
}

.input-with-button button {
  min-height: 36px;
  padding: 0 10px;
}
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-panel {
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-panel h1,
.section-head h2,
.brand h1 {
  margin: 0;
  letter-spacing: 0;
}

.auth-copy {
  margin: 8px 0 20px;
  color: var(--muted);
}

.auth-form {
  display: grid;
  gap: 14px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  gap: 18px;
  align-items: center;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
}

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

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: #192522;
  color: #d9fff6;
  font-weight: 800;
}

.brand h1 {
  font-size: 20px;
}

.brand p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.tab {
  min-height: 34px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.tab:hover,
.tab.active {
  background: #fff;
  color: var(--text);
}

.logout-form {
  margin: 0;
}

.workspace {
  width: min(1500px, calc(100vw - 28px));
  margin: 20px auto 48px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.section-head {
  display: flex;
  gap: 16px;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-head h2 {
  font-size: 24px;
}

.toolbar,
.actions,
.generator-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
}

.toolbar input[type="search"] {
  width: min(320px, 56vw);
}

.toolbar label,
.generator-controls label {
  min-width: 104px;
}

.notice {
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text);
}

.notice.error {
  border-color: #f3b8b0;
  background: #fff4f2;
  color: var(--danger);
}

.notice.ok {
  border-color: #b9ddd7;
  background: #edfaf7;
}

.split {
  display: grid;
  grid-template-columns: minmax(300px, 430px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

#lexicon-form,
#bulk-edit-form {
  grid-column: 1;
}

#view-lexicon > .split > .table-wrap {
  grid-column: 2;
  grid-row: 1 / span 2;
  min-width: 0;
}

.editor,
.settings-block {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.bulk-editor {
  display: grid;
  gap: 14px;
}

.bulk-editor[hidden] {
  display: none;
}

.bulk-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.bulk-editor-head h3,
.bulk-editor-head p {
  margin: 0;
}

.bulk-editor-head p {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.bulk-grid {
  display: grid;
  grid-template-columns: minmax(118px, auto) minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.bulk-apply {
  display: flex;
  grid-template-columns: none;
  flex-direction: row;
  align-items: center;
  gap: 7px;
  color: var(--text);
  font-size: 13px;
}

.bulk-apply input[type="checkbox"] {
  width: 18px;
  min-width: 18px;
  min-height: 18px;
}

.bulk-notes-label {
  align-self: start;
  padding-top: 8px;
}
.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field-grid.compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.wide {
  grid-column: 1 / -1;
}

.actions {
  margin-top: 14px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.table-wrap.shallow {
  max-height: 420px;
}

.data-table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid var(--line);
  padding: 8px 9px;
  text-align: left;
  vertical-align: top;
}

.data-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fbfa;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.data-table tbody tr:hover {
  background: #f7faf9;
}

.data-table td:last-child {
  white-space: nowrap;
}

.data-table button {
  min-height: 30px;
  padding: 0 9px;
}

.status-bulk {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 3px 5px 3px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.status-bulk span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status-bulk button {
  min-height: 28px;
  padding: 0 9px;
}

.select-col {
  width: 38px;
  min-width: 38px;
  text-align: center !important;
}

.select-col input[type="checkbox"] {
  width: 18px;
  min-width: 18px;
  min-height: 18px;
  margin: 0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.compact-table {
  min-width: 1100px;
}

.compact-table input,
.compact-table select {
  min-width: 84px;
}

.compact-table input[type="checkbox"] {
  min-width: 0;
  width: 18px;
  min-height: 18px;
}

.compact-table select[multiple] {
  min-height: 82px;
  min-width: 130px;
  padding: 5px;
}

.settings-stack {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.settings-block.wide-block {
  grid-column: 1 / -1;
}

.settings-stack .field-grid.compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.settings-block h3 {
  margin: 0 0 12px;
  font-size: 17px;
}

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

.grammar-editor {
  min-width: 0;
}

.grammar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.grammar-head h4 {
  margin: 0;
  font-size: 14px;
}

.grammar-table {
  min-width: 420px;
}

.inline-action {
  margin-top: 10px;
}

.generator-controls {
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.spec-view {
  min-height: 60vh;
  margin: 0;
  padding: 18px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111917;
  color: #e8f3ef;
  font: 14px/1.65 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
}

.empty {
  color: var(--muted);
}

@media (max-width: 1180px) {
  .grammar-grid {
    grid-template-columns: 1fr;
  }
}

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

  .section-head,
  .split,
  .settings-stack {
    display: grid;
    grid-template-columns: 1fr;
  }

  #lexicon-form,
  #bulk-edit-form,
  #view-lexicon > .split > .table-wrap {
    grid-column: 1;
    grid-row: auto;
  }

  .settings-block.wide-block {
    grid-column: auto;
  }

  .field-grid,
  .field-grid.compact,
  .settings-stack .field-grid.compact {
    grid-template-columns: 1fr;
  }
}
