:root {
  --brand-ink: #0b0f19;
  --brand-ink-strong: #05070d;
  --brand-muted: #6b7280;
  --brand-line: #e5e7eb;
  --brand-paper: #ffffff;
  --brand-wash: #fbfbfa;
  --brand-accent: #1f6feb;
  --radius-lg: 18px;
  --radius-md: 14px;
  --shadow-soft: 0 8px 24px rgba(17, 24, 39, 0.06);
  --shadow-card: 0 1px 0 rgba(17, 24, 39, 0.04);

  --pico-background-color: var(--brand-wash);
  --pico-card-background-color: var(--brand-paper);
  --pico-color: var(--brand-ink);
  --pico-muted-color: var(--brand-muted);
  --pico-muted-border-color: var(--brand-line);
  --pico-primary: var(--brand-accent);
  --pico-primary-hover: #195fd0;
  --pico-primary-focus: rgba(31, 111, 235, 0.22);
  --pico-form-element-border-color: var(--brand-line);
  --pico-form-element-background-color: var(--brand-paper);
  --pico-form-element-focus-color: rgba(31, 111, 235, 0.18);
  --pico-border-radius: 14px;
  --pico-font-family: ui-sans-serif, system-ui, -apple-system, "Hiragino Sans", "Yu Gothic", "Noto Sans TC",
    "Noto Sans JP", "PingFang TC", "Microsoft JhengHei", "Segoe UI", Arial, sans-serif;
}

body {
  background: var(--brand-wash);
  color: var(--brand-ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

main.container {
  max-width: 1040px;
  padding-top: 1rem;
  padding-bottom: 2.25rem;
}

.brand {
  font-weight: 740;
  letter-spacing: .02em;
  text-decoration: none;
  color: var(--brand-ink);
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 0 1.25rem 0;
  border-bottom: 1px solid var(--brand-line);
  margin-bottom: 1.25rem;
}

.site-footer {
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--brand-line);
  color: var(--brand-muted);
  font-size: .95rem;
}
.site-footer a { color: inherit; text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }

.section-gap {
  margin-top: 2rem;
}

h1 {
  letter-spacing: .01em;
  line-height: 1.25;
  color: var(--brand-ink-strong);
}

h2 {
  color: var(--brand-ink-strong);
}

p { line-height: 1.75; color: var(--brand-ink); }

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

.flash {
  padding: .75rem 1rem;
  border-radius: var(--radius-md);
  margin: .75rem 0;
  border: 1px solid var(--brand-line);
  background: var(--brand-paper);
  box-shadow: var(--shadow-card);
}
.flash-success { border-color: rgba(42, 127, 69, 0.35); }
.flash-error { border-color: rgba(180, 35, 24, 0.35); }

.row { display: flex; gap: 1rem; align-items: center; }
.row-between { justify-content: space-between; }
.actions { display: flex; gap: .5rem; }

.album-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.album-card {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  border: 1px solid var(--brand-line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--brand-paper);
  box-shadow: var(--shadow-card);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.album-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-soft);
  border-color: rgba(31, 111, 235, 0.22);
}
.album-card:focus { outline: 2px solid rgba(31, 111, 235, 0.25); outline-offset: 2px; }

.album-cover {
  width: 100%;
  background: #f4f6f8;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.album-cover img {
  width: 100%;
  height: auto;
  display: block;
}

.album-meta { flex: 1; padding: .85rem 1rem 1rem 1rem; }
.album-title { font-weight: 700; letter-spacing: .01em; }
.album-sub { color: var(--brand-muted); font-size: .9rem; margin-top: .25rem; }
.album-desc {
  color: var(--brand-muted);
  font-size: .95rem;
  margin-top: .35rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.admin-list { display: grid; gap: .85rem; margin-top: .5rem; }
.admin-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border: 1px solid var(--brand-line);
  border-radius: var(--radius-lg);
  padding: .85rem 1rem;
  background: var(--brand-paper);
  box-shadow: var(--shadow-card);
}
.admin-item-main { display: flex; align-items: center; gap: .85rem; min-width: 0; }
.admin-item-text { min-width: 0; }
.admin-thumb {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  object-fit: contain;
  background: #f4f6f8;
  border: 1px solid var(--brand-line);
  flex: 0 0 auto;
}
.admin-title { font-weight: 750; color: var(--brand-ink-strong); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.admin-item-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; justify-content: flex-end; }

article {
  border: 1px solid var(--brand-line);
  border-radius: var(--radius-lg);
  padding: 1rem 1rem;
  background: var(--brand-paper);
  box-shadow: var(--shadow-card);
}

.danger-zone { margin-top: 1.25rem; }
.danger-actions { display: grid; gap: 1rem; }

.h-compact { margin-bottom: .25rem; }
.meta-stack { margin-top: .75rem; display: grid; gap: .75rem; }
.label {
  font-size: .82rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--brand-muted);
  margin-bottom: .35rem;
}
.text-block {
  padding: .85rem 1rem;
  border: 1px solid var(--brand-line);
  border-radius: var(--radius-lg);
  background: #fff;
  box-shadow: var(--shadow-card);
}
.text-body {
  color: var(--brand-ink);
  line-height: 1.8;
  white-space: pre-wrap;
}
.prompt-block {
  padding: .85rem 1rem;
  border: 1px solid rgba(31, 111, 235, 0.18);
  border-radius: var(--radius-lg);
  background: rgba(31, 111, 235, 0.04);
  box-shadow: var(--shadow-card);
}
.prompt-bottom { margin-top: 1rem; }
.prompt-text {
  margin: 0;
  padding: 0;
  background: transparent;
  border: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: .95rem;
  line-height: 1.65;
  color: var(--brand-ink-strong);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

.edit-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1rem;
  align-items: start;
}
.edit-preview {
  border: 1px solid var(--brand-line);
  border-radius: var(--radius-lg);
  padding: 1rem;
  background: var(--brand-paper);
  box-shadow: var(--shadow-card);
}
.preview-img {
  width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  display: block;
  background: #f4f6f8;
}

.viewer {
  margin-top: 1rem;
  display: grid;
  gap: .75rem;
}
.viewer-frame {
  border: 1px solid var(--brand-line);
  border-radius: var(--radius-lg);
  background: var(--brand-paper);
  padding: .65rem;
  box-shadow: var(--shadow-card);
  position: relative;
}
.viewer-img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: var(--radius-md);
  background: #f4f6f8;
}
.viewer-nav {
  display: flex;
  gap: .5rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: .35rem;
}

.tap-nav { position: absolute; inset: .65rem; border-radius: var(--radius-md); overflow: hidden; }
.tap-zone { position: absolute; top: 0; bottom: 0; width: 50%; }
.tap-left { left: 0; }
.tap-right { right: 0; }
.tap-zone:focus { outline: none; }
@media (hover: hover) and (pointer: fine) {
  .tap-left:hover { background: linear-gradient(90deg, rgba(31, 111, 235, 0.10), rgba(31, 111, 235, 0)); }
  .tap-right:hover { background: linear-gradient(270deg, rgba(31, 111, 235, 0.10), rgba(31, 111, 235, 0)); }
}

/* Mobile optimizations */
@media (max-width: 640px) {
  main.container { padding-left: .85rem; padding-right: .85rem; padding-top: .75rem; }

  .site-header { padding: .75rem 0 1rem 0; margin-bottom: 1rem; }

  .row { flex-direction: column; align-items: stretch; }
  .actions { width: 100%; }
  .actions > * { width: 100%; }

  .album-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .85rem; }
  .album-meta { padding: .75rem .85rem .9rem .85rem; }

  .admin-item { flex-direction: column; align-items: stretch; gap: .85rem; }
  .admin-item-actions { justify-content: stretch; }
  .admin-item-actions > * { flex: 1 1 auto; }

  .edit-grid { grid-template-columns: 1fr; }

  .viewer-frame { padding: .45rem; border-radius: 16px; }
  .tap-nav { inset: .45rem; }
  .text-block, .prompt-block { padding: .75rem .85rem; border-radius: 16px; }

  .viewer-nav {
    position: sticky;
    bottom: .5rem;
    z-index: 5;
    padding: .5rem;
    border-radius: 16px;
    border: 1px solid rgba(229, 231, 235, 0.9);
    background: rgba(255, 255, 255, 0.86);
    backdrop-filter: blur(8px);
    box-shadow: 0 10px 24px rgba(17, 24, 39, 0.08);
  }
  .viewer-nav a[role="button"], .viewer-nav button {
    flex: 1 1 0;
    min-width: 0;
  }
}
