:root {
  color-scheme: light;
  --ink: #182022;
  --muted: #667174;
  --line: #dce4e4;
  --panel: #ffffff;
  --page: #f4f7f6;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --accent-soft: #d8f2ee;
  --rose: #b14568;
  --gold: #b6842f;
  --shadow: 0 18px 50px rgba(25, 42, 44, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--page);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 28px 20px;
  background: #172221;
  color: #f5fbfa;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  background: #21413e;
  color: #d8f2ee;
  font-weight: 800;
}

.brand h1,
.brand p,
.topbar h2,
.topbar p {
  margin: 0;
}

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

.brand p {
  margin-top: 3px;
  color: #a8b9b5;
  font-size: 13px;
}

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

.nav-item {
  width: 100%;
  padding: 11px 12px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #dce8e6;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(216, 242, 238, 0.12);
  color: #ffffff;
}

.stats-panel {
  margin-top: auto;
  padding: 16px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.stats-panel span {
  display: block;
  font-size: 32px;
  font-weight: 800;
}

.stats-panel small {
  color: #aec4c0;
}

.storage-badge {
  display: inline-flex;
  align-items: center;
  margin-top: 12px;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: #dce8e6;
  font-size: 12px;
  font-weight: 800;
}

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

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

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.topbar h2 {
  font-size: 26px;
}

.topbar p {
  margin-top: 7px;
  color: var(--muted);
}

.top-actions,
.form-actions,
.library-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 520px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.editor-panel,
.library-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.editor-panel {
  display: grid;
  gap: 16px;
  padding: 18px;
}

label {
  display: grid;
  gap: 7px;
  color: #314042;
  font-size: 13px;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfdfd;
  color: var(--ink);
  outline: none;
}

input,
select {
  min-height: 42px;
  padding: 0 12px;
}

textarea {
  resize: vertical;
  min-height: 86px;
  padding: 11px 12px;
  line-height: 1.5;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.upload-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.drop-zone {
  min-height: 112px;
  place-items: center;
  border: 1px dashed #9bb7b3;
  border-radius: 8px;
  background: #f7fbfa;
  color: #203332;
  text-align: center;
}

.drop-zone.dragging {
  border-color: var(--accent);
  background: var(--accent-soft);
}

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

.drop-zone small {
  color: var(--muted);
  font-weight: 500;
}

.drop-zone input,
.file-label input {
  display: none;
}

.file-summary {
  display: none;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.file-summary.active {
  display: grid;
}

.primary-btn,
.ghost-btn,
.icon-btn {
  min-height: 40px;
  border-radius: 7px;
  border: 1px solid transparent;
  padding: 0 14px;
  font-weight: 800;
}

.primary-btn {
  background: var(--accent);
  color: #ffffff;
}

.primary-btn:disabled {
  cursor: wait;
  opacity: 0.72;
}

.primary-btn:hover {
  background: var(--accent-strong);
}

.ghost-btn,
.icon-btn {
  border-color: var(--line);
  background: #ffffff;
  color: #203332;
}

.ghost-btn:hover,
.icon-btn:hover {
  border-color: #9bb7b3;
}

.file-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

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

.library-panel {
  min-height: 620px;
  padding: 16px;
}

.library-toolbar {
  margin-bottom: 14px;
}

.library-toolbar input {
  flex: 1;
}

.library-toolbar select {
  width: 116px;
}

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

.empty-state strong {
  color: var(--ink);
}

.empty-state.hidden {
  display: none;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.entry-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.entry-card:hover {
  border-color: #9bb7b3;
}

.thumb {
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  background: #e9efee;
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-body {
  display: grid;
  gap: 9px;
  padding: 12px;
}

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

.card-title h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.3;
}

.favorite-btn {
  min-width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: var(--gold);
}

.card-prompt {
  display: -webkit-box;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  padding: 4px 7px;
  border-radius: 999px;
  background: #eef4f3;
  color: #415254;
  font-size: 12px;
}

.card-actions {
  display: flex;
  gap: 8px;
}

.card-actions button {
  flex: 1;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: #203332;
  font-weight: 700;
}

.card-actions .danger {
  color: var(--rose);
}

dialog {
  width: min(900px, calc(100vw - 28px));
  max-height: min(820px, calc(100vh - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(15, 28, 29, 0.45);
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.dialog-head h3 {
  margin: 0;
}

.dialog-body {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.detail-image {
  max-width: 100%;
  max-height: 420px;
  border-radius: 8px;
  object-fit: contain;
  background: #e9efee;
}

.copy-block {
  display: grid;
  gap: 8px;
}

.copy-block pre {
  max-height: 260px;
  overflow: auto;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f7fbfa;
  white-space: pre-wrap;
  word-break: break-word;
}

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

  .sidebar {
    position: static;
    display: grid;
    grid-template-columns: 1fr;
  }

  .stats-panel {
    display: none;
  }
}

@media (max-width: 640px) {
  .main,
  .sidebar {
    padding: 18px;
  }

  .topbar,
  .field-row,
  .upload-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .top-actions {
    justify-content: stretch;
  }

  .top-actions > * {
    flex: 1;
  }
}
