:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #eef7f6;
  --ink: #18222f;
  --muted: #617083;
  --line: #d9e1ea;
  --teal: #008b95;
  --teal-dark: #05636f;
  --pink: #b54891;
  --green: #4a9b55;
  --amber: #c27b18;
  --danger: #bd3145;
  --shadow: 0 16px 40px rgba(24, 34, 47, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(0, 139, 149, 0.08), transparent 320px),
    var(--bg);
  color: var(--ink);
}

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

button {
  border: 0;
}

a {
  color: inherit;
}

.app-shell {
  min-height: 100vh;
}

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

.boot-screen {
  align-content: center;
  gap: 16px;
  color: var(--muted);
}

.mark {
  display: grid;
  width: 64px;
  height: 64px;
  place-items: center;
  border-radius: 8px;
  background: var(--teal);
  color: #fff;
  font-weight: 800;
}

.login-panel {
  width: min(440px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
}

.brand-title {
  margin: 0;
  font-size: 1.45rem;
  line-height: 1.2;
}

.brand-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

.field label,
.small-label {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.field input,
.field textarea,
.field select,
.search-input,
.score-number {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.field input,
.search-input,
.score-number {
  min-height: 44px;
  padding: 10px 12px;
}

.field textarea {
  min-height: 110px;
  padding: 12px;
  resize: vertical;
}

.field input:focus,
.field textarea:focus,
.field select:focus,
.search-input:focus,
.score-number:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(0, 139, 149, 0.14);
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.danger-btn,
.icon-btn {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
  transition:
    transform 0.12s ease,
    box-shadow 0.12s ease,
    background 0.12s ease;
}

.primary-btn {
  width: 100%;
  padding: 0 16px;
  background: var(--teal);
  color: #fff;
  box-shadow: 0 8px 18px rgba(0, 139, 149, 0.24);
}

.primary-btn:hover,
.secondary-btn:hover,
.ghost-btn:hover,
.danger-btn:hover,
.icon-btn:hover {
  transform: translateY(-1px);
}

.secondary-btn {
  padding: 0 14px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.ghost-btn {
  padding: 0 12px;
  background: transparent;
  color: var(--muted);
}

.danger-btn {
  padding: 0 14px;
  background: #fff1f3;
  color: var(--danger);
}

.icon-btn {
  width: 40px;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

.primary-btn:disabled,
.secondary-btn:disabled,
.ghost-btn:disabled,
.danger-btn:disabled {
  cursor: wait;
  opacity: 0.65;
  transform: none;
}

.error-text,
.notice-text {
  min-height: 22px;
  margin: 12px 0 0;
  font-size: 0.92rem;
  line-height: 1.45;
}

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

.notice-text {
  color: var(--teal-dark);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(14px);
}

.topbar h1 {
  margin: 0;
  font-size: 1.1rem;
  line-height: 1.2;
}

.topbar-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.pill {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  background: var(--surface-soft);
  color: var(--teal-dark);
  font-size: 0.86rem;
  font-weight: 800;
  white-space: nowrap;
}

.pill.pink {
  background: #faedf6;
  color: var(--pink);
}

.pill.green {
  background: #edf8ef;
  color: var(--green);
}

.pill.amber {
  background: #fff6e8;
  color: var(--amber);
}

.workspace {
  display: grid;
  min-height: calc(100vh - 69px);
  grid-template-columns: 360px minmax(0, 1fr);
}

.side-panel {
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.74);
}

.side-toolbar {
  display: grid;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.progress-block {
  display: grid;
  gap: 9px;
}

.progress-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.progress-track {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #dfe9ef;
}

.progress-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--pink));
}

.article-list {
  display: grid;
  max-height: calc(100vh - 210px);
  overflow: auto;
  padding: 10px;
  gap: 8px;
}

.article-item {
  display: grid;
  width: 100%;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  padding: 12px;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.article-item:hover,
.article-item.active {
  border-color: var(--line);
  background: #fff;
}

.article-item.active {
  box-shadow: 0 8px 22px rgba(24, 34, 47, 0.08);
}

.article-title {
  overflow-wrap: anywhere;
  font-weight: 850;
}

.article-subtitle,
.muted {
  color: var(--muted);
}

.article-subtitle {
  margin-top: 5px;
  font-size: 0.9rem;
  line-height: 1.35;
}

.score-chip {
  align-self: start;
  min-width: 54px;
  border-radius: 8px;
  padding: 6px 7px;
  background: #eef7f6;
  color: var(--teal-dark);
  font-size: 0.88rem;
  font-weight: 900;
  text-align: center;
}

.score-chip.empty {
  background: #f0f2f5;
  color: var(--muted);
}

.main-panel {
  min-width: 0;
  padding: 24px;
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 370px;
  gap: 18px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 10px 26px rgba(24, 34, 47, 0.06);
}

.panel-header,
.panel-body,
.panel-footer {
  padding: 18px;
}

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

.panel-footer {
  border-top: 1px solid var(--line);
}

.title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.article-heading {
  margin: 8px 0 0;
  overflow-wrap: anywhere;
  font-size: clamp(1.35rem, 2.5vw, 2.05rem);
  line-height: 1.15;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.meta-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.meta-box span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.meta-box strong {
  overflow-wrap: anywhere;
}

.link-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.content-box {
  max-height: 46vh;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: #273648;
  line-height: 1.62;
}

.empty-state {
  display: grid;
  min-height: 300px;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
  color: var(--muted);
  text-align: center;
}

.score-panel {
  position: sticky;
  top: 90px;
}

.score-total {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 14px;
}

.total-number {
  font-size: 2.45rem;
  font-weight: 950;
  line-height: 1;
  color: var(--teal-dark);
}

.criteria-list {
  display: grid;
  gap: 16px;
}

.criterion {
  display: grid;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
}

.criterion:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.criterion-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
}

.criterion-title {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 0.98rem;
  line-height: 1.3;
}

.criterion-help {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}

.weight-badge {
  border-radius: 8px;
  padding: 6px 8px;
  background: #faedf6;
  color: var(--pink);
  font-weight: 950;
}

.score-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 78px;
  gap: 12px;
  align-items: center;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--teal);
}

.score-number {
  min-height: 40px;
  padding: 8px;
  text-align: center;
  font-weight: 850;
}

.note-area {
  min-height: 82px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 18px 22px 0;
}

.tab-btn {
  min-height: 38px;
  border-radius: 8px;
  padding: 0 13px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 850;
}

.tab-btn.active {
  background: var(--ink);
  color: #fff;
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  gap: 18px;
  padding: 22px;
}

.admin-stack {
  display: grid;
  gap: 18px;
  padding: 22px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px;
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f7fafc;
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
}

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

.row-action {
  width: 100%;
}

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

.form-grid .span-2 {
  grid-column: 1 / -1;
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.split-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.import-box {
  min-height: 180px;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.48);
}

.modal {
  width: min(460px, 100%);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.25);
}

.hidden {
  display: none !important;
}

@media (max-width: 1100px) {
  .workspace,
  .detail-layout,
  .admin-layout {
    grid-template-columns: 1fr;
  }

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

  .article-list {
    grid-auto-flow: column;
    grid-auto-columns: minmax(250px, 68vw);
    max-height: none;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 14px;
  }

  .score-panel {
    position: static;
  }
}

@media (max-width: 720px) {
  body {
    background:
      linear-gradient(180deg, rgba(0, 139, 149, 0.1), transparent 220px),
      #f7f9fc;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
    padding: 12px 14px;
  }

  .topbar-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-content: stretch;
    width: 100%;
  }

  .topbar-meta .secondary-btn,
  .topbar-meta .ghost-btn,
  .topbar-meta .pill {
    width: 100%;
  }

  .topbar-meta .ghost-btn {
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
  }

  .topbar-meta .pill {
    justify-content: center;
    white-space: normal;
    text-align: center;
  }

  .topbar-meta > button:last-child {
    grid-column: 1 / -1;
  }

  .workspace {
    display: block;
    min-height: auto;
  }

  .side-panel {
    background: rgba(255, 255, 255, 0.95);
  }

  .side-toolbar {
    padding: 12px 14px;
  }

  .article-list {
    grid-auto-flow: row;
    grid-auto-columns: unset;
    max-height: 38vh;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 10px 14px 14px;
  }

  .article-item {
    border-color: var(--line);
    background: #fff;
    padding: 11px;
  }

  .article-item.active {
    border-color: var(--teal);
    box-shadow: inset 3px 0 0 var(--teal);
  }

  .article-subtitle {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .main-panel,
  .admin-layout,
  .admin-stack {
    padding: 12px;
  }

  .detail-layout,
  .admin-layout {
    gap: 12px;
  }

  .panel {
    box-shadow: none;
  }

  .panel-header,
  .panel-body,
  .panel-footer {
    padding: 12px;
  }

  .title-row,
  .split-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .meta-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .article-heading {
    font-size: 1.28rem;
    line-height: 1.2;
  }

  .meta-grid {
    gap: 8px;
  }

  .meta-box {
    padding: 10px;
  }

  .link-actions,
  .inline-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .link-actions > *,
  .inline-actions > *,
  .split-actions > * {
    width: 100%;
  }

  .content-box {
    max-height: none;
    font-size: 0.96rem;
    line-height: 1.58;
  }

  .score-total,
  .score-control {
    grid-template-columns: 1fr;
  }

  .total-number {
    font-size: 2.15rem;
  }

  input[type="range"] {
    min-height: 34px;
  }

  .score-number {
    text-align: left;
  }

  .login-panel {
    padding: 22px;
  }

  .tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding: 12px 12px 0;
  }

  .tab-btn {
    padding: 0 8px;
    font-size: 0.9rem;
  }

  .table-wrap {
    overflow: visible;
    border: 0;
    background: transparent;
  }

  table {
    display: block;
    min-width: 0;
  }

  thead {
    display: none;
  }

  tbody {
    display: grid;
    gap: 10px;
  }

  tr {
    display: grid;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 10px;
  }

  td {
    display: grid;
    grid-template-columns: minmax(92px, 36%) minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    border-bottom: 1px dashed var(--line);
    padding: 8px 2px;
    overflow-wrap: anywhere;
  }

  tr:last-child td {
    border-bottom: 1px dashed var(--line);
  }

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

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

  td[data-label=""] {
    grid-template-columns: 1fr;
  }

  td[data-label=""]::before {
    content: none;
  }

  td.empty-rank {
    display: none;
  }

  .row-action {
    min-height: 42px;
  }

  .import-box {
    min-height: 150px;
  }

  .modal-backdrop {
    align-items: end;
    padding: 0;
  }

  .modal {
    width: 100%;
    border-radius: 8px 8px 0 0;
  }
}
