:root {
  color-scheme: light;
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-2: #edf1ef;
  --line: #d8dedb;
  --line-strong: #b8c3be;
  --text: #1d2924;
  --muted: #65736d;
  --accent: #0b766e;
  --accent-strong: #075a54;
  --accent-soft: #dff0ee;
  --warn: #9a5a00;
  --danger: #ad342f;
  --gold: #e5b45a;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
  white-space: nowrap;
}

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

button:disabled {
  cursor: default;
  opacity: 0.5;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

button.primary:hover {
  background: var(--accent-strong);
  color: white;
}

button.danger,
.file-delete {
  color: var(--danger);
}

input,
select {
  min-width: 0;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 12px;
}

input:focus-visible,
select:focus-visible,
button:focus-visible {
  outline: 3px solid rgba(11, 118, 110, 0.2);
  outline-offset: 2px;
}

.hidden {
  display: none !important;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 18px 48px rgba(31, 41, 36, 0.12);
}

.login-panel label,
.field,
.title-field {
  display: grid;
  gap: 7px;
}

.login-panel label span,
.field span,
.title-field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

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

.mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: #243630;
  color: var(--gold);
  font-weight: 900;
  font-size: 13px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 21px;
  line-height: 1.1;
  letter-spacing: 0;
}

.brand-line p,
.editor-name,
#recordCount {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 18px;
  align-items: center;
  padding: 16px clamp(16px, 3vw, 34px);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

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

.sidebar {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  border-right: 1px solid var(--line);
  background: var(--surface-2);
}

.list-tools {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.acts {
  overflow: auto;
  padding: 8px;
}

.act-row {
  min-height: 68px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  padding: 6px;
  border: 1px solid transparent;
  border-radius: 8px;
}

.act-row:hover {
  background: rgba(255, 255, 255, 0.7);
}

.act-row.active {
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 5px 18px rgba(11, 118, 110, 0.1);
}

.act-select {
  width: 100%;
  min-height: 54px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 6px 4px 6px 6px;
  border: 0;
  background: transparent;
  text-align: left;
  white-space: normal;
}

.act-row-name,
.file-name {
  overflow-wrap: anywhere;
  font-weight: 760;
  line-height: 1.25;
}

.badges {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.badge {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: #dce3df;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
}

.badge.on {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.reorder-actions {
  display: grid;
  gap: 4px;
}

.reorder-actions button {
  min-height: 27px;
  padding: 0 8px;
  font-size: 11px;
}

.unused-section {
  max-height: 34vh;
  overflow: auto;
  padding: 12px;
  border-top: 1px solid var(--line);
}

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

.section-head h2 {
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0;
  text-transform: uppercase;
}

.section-head span {
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.unused-files {
  display: grid;
  gap: 6px;
}

.unused-empty {
  color: var(--muted);
  font-size: 13px;
  padding: 10px 2px;
}

.file-row {
  min-height: 58px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.75);
}

.file-meta {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.file-delete {
  min-height: 34px;
  padding: 0 10px;
}

.editor {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 22px;
  padding: clamp(18px, 4vw, 42px);
}

.editor-head {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.act-title {
  min-height: 50px;
  font-size: 24px;
  font-weight: 780;
}

.field-grid {
  display: grid;
  gap: 14px;
  max-width: 980px;
}

.tool-band {
  display: grid;
  gap: 10px;
  max-width: 980px;
  padding-top: 4px;
  border-top: 1px solid var(--line);
}

.upload-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(180px, 240px) auto auto auto;
  gap: 10px;
  align-items: center;
}

.publish-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 10px;
}

.check {
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-weight: 700;
}

.check input {
  min-height: auto;
}

.publish-log {
  min-height: 170px;
  max-height: 360px;
  overflow: auto;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #17231f;
  color: #d8efe8;
  font: 13px/1.45 "Cascadia Mono", "Consolas", monospace;
  white-space: pre-wrap;
}

.status {
  min-height: 26px;
  color: var(--muted);
  font-weight: 700;
}

.status.dirty {
  color: var(--warn);
}

.status.error {
  color: var(--danger);
}

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

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: 48vh;
  }

  .upload-grid,
  .publish-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .topbar,
  .editor {
    padding: 14px;
  }

  .top-actions,
  .editor-head {
    display: grid;
    grid-template-columns: 1fr;
    justify-content: stretch;
  }

  .top-actions button {
    width: 100%;
  }

  .act-title {
    font-size: 20px;
  }
}
