:root {
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #f5f6f8;
  --panel: #ffffff;
  --primary: #0d6b6f;
  --gold: #b8893b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

.admin-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.admin-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px;
  color: white;
  background: #0b1b25;
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 34px;
}

.admin-brand.center {
  justify-content: center;
  color: var(--ink);
  margin-bottom: 20px;
}

.admin-brand span {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: #f8d992;
  border: 1px solid rgba(248, 217, 146, 0.42);
  border-radius: 50%;
  font-weight: 800;
}

.admin-sidebar nav {
  display: grid;
  gap: 8px;
}

.admin-sidebar a,
.admin-sidebar button {
  width: 100%;
  display: flex;
  padding: 12px 14px;
  color: rgba(255, 255, 255, 0.72);
  background: transparent;
  border: 0;
  border-radius: 8px;
  font: inherit;
  cursor: pointer;
}

.admin-sidebar a.active,
.admin-sidebar a:hover,
.admin-sidebar button:hover {
  color: white;
  background: rgba(255, 255, 255, 0.09);
}

.admin-sidebar form {
  margin-top: 28px;
}

.admin-main {
  padding: 34px;
}

.login-main {
  grid-column: 1 / -1;
  display: grid;
  place-items: center;
  padding: 30px;
  background:
    linear-gradient(135deg, rgba(11, 27, 37, 0.92), rgba(13, 107, 111, 0.76)),
    #0b1b25;
}

.login-card {
  width: min(430px, 100%);
  padding: 34px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.22);
}

.login-card h1 {
  text-align: center;
  margin: 0 0 10px;
}

.login-card p {
  color: var(--muted);
  text-align: center;
  line-height: 1.6;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 26px;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.admin-header span {
  color: var(--gold);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.14em;
}

.admin-header h1 {
  margin: 6px 0 0;
  font-size: 32px;
}

.panel,
.stats-grid article {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(17, 24, 39, 0.04);
}

.panel {
  padding: 24px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.stats-grid article {
  padding: 24px;
}

.stats-grid strong {
  display: block;
  font-size: 28px;
  overflow-wrap: anywhere;
}

.stats-grid span,
.table-row span,
label {
  color: var(--muted);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.panel-head h2 {
  margin: 0;
}

.table {
  display: grid;
}

.table-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: center;
  padding: 18px 0;
  border-top: 1px solid var(--line);
}

.table-row:first-child {
  border-top: 0;
}

.table-row strong,
.table-row span {
  display: block;
}

.post-row {
  grid-template-columns: auto 1fr auto auto;
}

.post-row > div:first-child {
  min-width: 0;
}

.row-cover {
  width: 72px;
  height: 54px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.badge {
  width: fit-content;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.badge.published {
  color: #075985;
  background: #e0f2fe;
}

.badge.draft {
  color: #92400e;
  background: #fef3c7;
}

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

.row-actions a,
.row-actions button,
.link-button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.primary,
.link-button.primary {
  min-height: 42px;
  padding: 0 18px;
  border: 0;
  border-radius: 8px;
  color: white;
  background: var(--primary);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

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

.form-stack {
  display: grid;
  gap: 16px;
}

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

label {
  display: grid;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  padding: 12px 13px;
  color: var(--ink);
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
}

textarea {
  resize: vertical;
  line-height: 1.7;
}

.checkline {
  display: flex;
  align-items: center;
  gap: 8px;
}

.checkline input {
  width: auto;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
}

.admin-grid.two {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 20px;
  margin-bottom: 20px;
}

.quick-grid {
  display: grid;
  gap: 12px;
}

.quick-grid a {
  display: grid;
  gap: 4px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfe;
}

.quick-grid span,
.panel-head span,
.empty,
.usage,
.meta-line {
  color: var(--muted);
}

.media-strip,
.media-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
}

.media-thumb,
.media-picker button {
  min-width: 0;
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  font: inherit;
  text-align: left;
}

.media-thumb img,
.media-picker img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 6px;
  background: #eef2f7;
}

.media-thumb span,
.media-picker span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.file-icon {
  width: 100%;
  aspect-ratio: 4 / 3;
  display: grid;
  place-items: center;
  color: #0d6b6f;
  background: #e9f6f5;
  border: 1px solid #b7ddda;
  border-radius: 6px;
  font-weight: 900;
}

.file-icon.small {
  width: 100%;
  min-height: 80px;
}

.field-label {
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  margin-bottom: 8px;
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: #f9fafb;
}

.editor-toolbar button,
.subtle {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.rich-editor,
.editor-source,
.editor-preview {
  min-height: 340px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 0 0 8px 8px;
  background: white;
  outline: none;
  line-height: 1.8;
}

.editor-source,
.editor-preview {
  display: none;
}

[data-mode="source"] .rich-editor,
[data-mode="source"] .editor-preview,
[data-mode="preview"] .rich-editor,
[data-mode="preview"] .editor-source {
  display: none;
}

[data-mode="source"] .editor-source,
[data-mode="preview"] .editor-preview {
  display: block;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.picker-panel {
  padding: 16px;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  background: #fbfdfe;
}

.panel-head.tight {
  margin-bottom: 10px;
}

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

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.media-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.media-preview img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: 6px;
  background: #eef2f7;
}

.media-meta {
  display: grid;
  gap: 8px;
}

code {
  display: block;
  max-width: 100%;
  padding: 8px;
  overflow: auto;
  color: #334155;
  background: #f1f5f9;
  border-radius: 6px;
  font-size: 12px;
}

.meta-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
}

.danger {
  width: 100%;
  min-height: 38px;
  border: 1px solid #fecaca;
  border-radius: 8px;
  color: #991b1b;
  background: #fff1f2;
  font: inherit;
  cursor: pointer;
}

.danger:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.flash {
  padding: 12px 14px;
  margin-bottom: 18px;
  border-radius: 8px;
  font-weight: 700;
}

.flash.success {
  color: #065f46;
  background: #d1fae5;
}

.flash.error {
  color: #991b1b;
  background: #fee2e2;
}

@media (max-width: 900px) {
  .admin-shell {
    grid-template-columns: 1fr;
  }

  .admin-sidebar {
    position: static;
    height: auto;
  }

  .stats-grid,
  .form-grid,
  .admin-grid.two,
  .upload-form {
    grid-template-columns: 1fr;
  }

  .post-row,
  .table-row {
    grid-template-columns: 1fr;
  }

  .admin-header {
    align-items: flex-start;
    flex-direction: column;
  }
}

/* 2026 media-first admin refresh */
:root {
  --bg: #f3f6fa;
  --primary: #007c89;
  --primary-dark: #075463;
  --accent: #356bff;
}

.admin-sidebar {
  background:
    linear-gradient(180deg, #07111f, #0b2738 58%, #0a3b3f);
}

.admin-sidebar a.active {
  background: rgba(140, 230, 255, 0.14);
}

.admin-header h1 {
  letter-spacing: 0;
}

.panel,
.stats-grid article {
  border-radius: 8px;
}

.panel-head > div {
  display: grid;
  gap: 5px;
}

.media-stats article:nth-child(3) strong {
  color: var(--primary);
}

.media-workbench {
  align-items: stretch;
}

.upload-form.stacked {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  align-items: stretch;
}

.form-grid.compact {
  gap: 14px;
}

.drop-zone {
  min-height: 150px;
  place-items: center;
  padding: 24px;
  border: 1px dashed #99b6c8;
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(0,124,137,.08) 1px, transparent 1px) 0 0 / 28px 28px,
    linear-gradient(0deg, rgba(53,107,255,.06) 1px, transparent 1px) 0 0 / 28px 28px,
    #f8fbff;
  text-align: center;
}

.drop-zone span {
  color: var(--primary);
  font-size: 13px;
  font-weight: 900;
}

.drop-zone strong {
  color: var(--ink);
  font-size: 18px;
}

.drop-zone input {
  max-width: 360px;
  background: white;
}

.media-toolbar {
  gap: 16px;
  align-items: flex-start;
}

.media-filter {
  min-width: min(520px, 100%);
  display: grid;
  grid-template-columns: 150px 1fr auto;
  gap: 10px;
}

.media-filter button {
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  cursor: pointer;
}

.media-grid.enhanced {
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.media-card {
  border-radius: 8px;
  transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease;
}

.media-card:hover {
  border-color: rgba(0, 124, 137, 0.3);
  box-shadow: 0 16px 46px rgba(17, 24, 39, 0.08);
  transform: translateY(-2px);
}

.media-preview {
  min-height: 180px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 8px;
  background: #edf3f8;
}

.media-preview img,
.media-preview video,
.media-preview iframe,
.media-thumb video,
.media-picker video {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  display: block;
  border: 0;
  border-radius: 8px;
  background: #0b1220;
}

.media-preview iframe {
  aspect-ratio: 16 / 9;
}

.media-kind-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.badge.media-kind {
  color: var(--primary-dark);
  background: #e7f8fb;
  border: 1px solid #b9e8ef;
}

.row-actions.wrap {
  flex-wrap: wrap;
}

.admin-media-strip {
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}

.quick-project {
  display: grid;
  gap: 5px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfe;
}

.quick-project strong {
  color: var(--primary-dark);
}

.quick-project span {
  color: var(--muted);
  line-height: 1.6;
}

.compact-media-stats {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 0;
}

.compact-media-stats article {
  padding: 18px;
}

.media-picker button {
  cursor: pointer;
}

.media-picker button:hover {
  border-color: rgba(0, 124, 137, 0.36);
}

@media (max-width: 900px) {
  .media-filter,
  .compact-media-stats {
    grid-template-columns: 1fr;
  }
}

/* Compact operations UI pass */
:root {
  --compact-radius: 6px;
  --compact-shadow: 0 8px 22px rgba(17, 24, 39, 0.035);
}

body {
  background: #f4f6f8;
  font-size: 14px;
}

.admin-shell {
  grid-template-columns: 224px minmax(0, 1fr);
}

.admin-sidebar {
  padding: 18px 14px;
}

.admin-brand {
  gap: 9px;
  margin-bottom: 22px;
}

.admin-brand span {
  width: 34px;
  height: 34px;
  border-radius: var(--compact-radius);
  font-size: 12px;
}

.admin-brand strong {
  font-size: 15px;
}

.admin-sidebar nav {
  gap: 4px;
}

.admin-sidebar a,
.admin-sidebar button {
  min-height: 34px;
  padding: 8px 10px;
  border-radius: var(--compact-radius);
  font-size: 13px;
}

.admin-sidebar form {
  margin-top: 18px;
}

.admin-main {
  padding: 22px 24px;
}

.admin-header {
  margin-bottom: 16px;
}

.admin-header span {
  font-size: 11px;
  letter-spacing: 0.08em;
}

.admin-header h1 {
  margin-top: 3px;
  font-size: 24px;
  line-height: 1.2;
}

.header-actions {
  gap: 8px;
}

.panel,
.stats-grid article {
  border-radius: var(--compact-radius);
  box-shadow: var(--compact-shadow);
}

.panel {
  padding: 16px;
}

.panel + .panel,
.admin-grid.two + .panel,
.panel + .admin-grid.two {
  margin-top: 14px;
}

.panel-head {
  margin-bottom: 10px;
}

.panel-head h2 {
  font-size: 17px;
  line-height: 1.25;
}

.panel-head span {
  font-size: 12px;
  line-height: 1.45;
}

.stats-grid {
  gap: 10px;
  margin-bottom: 14px;
}

.stats-grid article {
  min-height: 72px;
  padding: 14px 16px;
}

.stats-grid strong {
  font-size: 22px;
  line-height: 1.1;
}

.stats-grid span {
  margin-top: 4px;
  font-size: 12px;
}

.admin-grid.two {
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.75fr);
  gap: 14px;
  margin-bottom: 14px;
}

.table-row {
  gap: 12px;
  padding: 11px 0;
}

.table-row strong {
  font-size: 14px;
}

.table-row span {
  margin-top: 3px;
  font-size: 12px;
}

.post-row {
  grid-template-columns: auto minmax(0, 1fr) auto auto;
}

.row-cover {
  width: 54px;
  height: 40px;
  border-radius: var(--compact-radius);
}

.badge {
  padding: 3px 8px;
  font-size: 11px;
}

.row-actions {
  gap: 6px;
}

.row-actions a,
.row-actions button,
.link-button,
.media-filter button {
  min-height: 32px;
  padding: 0 10px;
  border-radius: var(--compact-radius);
  font-size: 13px;
}

.primary,
.link-button.primary,
.danger {
  min-height: 34px;
  padding: 0 12px;
  border-radius: var(--compact-radius);
  font-size: 13px;
}

.form-grid {
  gap: 12px;
}

.form-stack {
  gap: 11px;
}

label {
  gap: 6px;
  font-size: 12px;
}

input,
textarea,
select {
  min-height: 34px;
  padding: 8px 10px;
  border-radius: var(--compact-radius);
  font-size: 13px;
}

textarea {
  line-height: 1.55;
}

.quick-grid {
  gap: 8px;
}

.quick-grid a,
.quick-project {
  padding: 12px;
  border-radius: var(--compact-radius);
}

.quick-grid strong,
.quick-project strong {
  font-size: 14px;
}

.quick-grid span,
.quick-project span {
  font-size: 12px;
  line-height: 1.5;
}

.media-strip,
.media-picker {
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 8px;
}

.media-thumb,
.media-picker button {
  gap: 6px;
  padding: 7px;
  border-radius: var(--compact-radius);
}

.media-thumb img,
.media-picker img,
.media-thumb video,
.media-picker video {
  aspect-ratio: 5 / 3;
  border-radius: 5px;
}

.media-thumb span,
.media-picker span {
  font-size: 12px;
}

.file-icon {
  aspect-ratio: 5 / 3;
  border-radius: 5px;
  font-size: 12px;
}

.file-icon.small {
  min-height: 58px;
}

.editor-toolbar {
  gap: 5px;
  padding: 7px;
  border-radius: var(--compact-radius) var(--compact-radius) 0 0;
}

.editor-toolbar button,
.subtle {
  min-height: 28px;
  padding: 0 8px;
  border-radius: 5px;
  font-size: 12px;
}

.rich-editor,
.editor-source,
.editor-preview {
  min-height: 230px;
  padding: 12px;
  border-radius: 0 0 var(--compact-radius) var(--compact-radius);
  line-height: 1.65;
  font-size: 14px;
}

.picker-panel {
  padding: 12px;
  border-radius: var(--compact-radius);
}

.upload-form.stacked {
  gap: 11px;
}

.drop-zone {
  min-height: 96px;
  padding: 14px;
  border-radius: var(--compact-radius);
  background:
    linear-gradient(90deg, rgba(0,124,137,.06) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(0deg, rgba(53,107,255,.04) 1px, transparent 1px) 0 0 / 24px 24px,
    #f8fbff;
}

.drop-zone strong {
  font-size: 15px;
}

.drop-zone input {
  max-width: 320px;
}

.media-filter {
  min-width: min(460px, 100%);
  grid-template-columns: 120px minmax(150px, 1fr) auto;
  gap: 7px;
}

.media-grid {
  gap: 10px;
}

.media-grid.enhanced {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.media-card {
  gap: 8px;
  padding: 10px;
  border-radius: var(--compact-radius);
}

.media-card:hover {
  transform: none;
  box-shadow: 0 10px 28px rgba(17, 24, 39, 0.06);
}

.media-preview {
  min-height: 112px;
  border-radius: var(--compact-radius);
}

.media-preview img,
.media-preview video,
.media-preview iframe {
  aspect-ratio: 16 / 8.5;
  border-radius: var(--compact-radius);
}

.media-preview iframe {
  min-height: 112px;
}

.media-meta {
  gap: 6px;
}

.media-kind-line,
.meta-line {
  font-size: 12px;
}

code {
  max-height: 44px;
  padding: 6px 7px;
  border-radius: 5px;
  font-size: 11px;
}

.usage {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
}

.flash {
  padding: 9px 11px;
  margin-bottom: 12px;
  border-radius: var(--compact-radius);
  font-size: 13px;
}

.login-card {
  width: min(390px, 100%);
  padding: 26px;
  border-radius: 8px;
}

.login-card h1 {
  font-size: 24px;
}

.login-card p {
  margin: 0 0 14px;
  font-size: 13px;
}

@media (max-width: 900px) {
  .admin-main {
    padding: 16px;
  }

  .admin-sidebar {
    padding: 14px;
  }

  .stats-grid,
  .media-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .media-filter {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .stats-grid,
  .media-stats {
    grid-template-columns: 1fr;
  }
}
