:root {
  --bg: #f3efe7;
  --panel: rgba(255, 250, 242, 0.9);
  --panel-strong: #fffdf7;
  --ink: #1f2933;
  --muted: #5b6770;
  --line: rgba(74, 85, 104, 0.18);
  --accent: #b45309;
  --accent-dark: #8b3d07;
  --danger: #b42318;
  --shadow: 0 18px 45px rgba(61, 42, 24, 0.12);
}

html.password-gate-active body {
  min-height: 100vh;
}

.password-gate-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.password-gate-card {
  width: min(520px, 100%);
  padding: 30px;
  border-radius: 28px;
  background: rgba(255, 250, 242, 0.94);
  border: 1px solid rgba(180, 83, 9, 0.18);
  box-shadow: 0 24px 60px rgba(61, 42, 24, 0.16);
  backdrop-filter: blur(12px);
}

.password-gate-eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 12px;
  font-weight: 700;
}

.password-gate-card h1 {
  margin: 0;
  font-size: clamp(28px, 6vw, 42px);
  line-height: 1.1;
}

.password-gate-copy {
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.password-gate-form {
  margin-top: 22px;
  display: grid;
  gap: 14px;
}

.password-gate-form label {
  display: grid;
  gap: 8px;
}

.password-gate-form label span {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: #334155;
}

.password-gate-error {
  min-height: 22px;
  margin: 0;
  color: var(--danger);
  font-size: 14px;
}

.password-gate-form button {
  border: 0;
  border-radius: 16px;
  padding: 14px 18px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.16s ease, transform 0.16s ease;
}

.password-gate-form button:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(160, 202, 244, 0.52), transparent 28%),
    radial-gradient(circle at top right, rgba(214, 236, 255, 0.42), transparent 24%),
    linear-gradient(135deg, #edf5fd 0%, #f6fbff 48%, #e1eefb 100%);
  min-height: 100vh;
}

button,
input,
textarea {
  font: inherit;
}

.page-shell {
  width: min(1200px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  margin-bottom: 28px;
  padding: 28px;
  background:
    radial-gradient(circle at 18% 20%, rgba(255, 255, 255, 0.54), transparent 30%),
    radial-gradient(circle at 82% 18%, rgba(182, 218, 255, 0.44), transparent 24%),
    linear-gradient(135deg, rgba(104, 151, 210, 0.94) 0%, rgba(134, 179, 233, 0.92) 48%, rgba(187, 220, 248, 0.94) 100%);
  border: 1px solid rgba(124, 170, 222, 0.32);
  border-radius: 24px;
  box-shadow: 0 22px 48px rgba(76, 119, 171, 0.2);
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.08) 0,
      rgba(255, 255, 255, 0.08) 1px,
      transparent 1px,
      transparent 36px
    );
  mask-image: linear-gradient(90deg, rgba(0, 0, 0, 0.2), transparent 82%);
  pointer-events: none;
}

.hero::after {
  content: "";
  position: absolute;
  inset: auto -40px -55px auto;
  width: 240px;
  height: 240px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(220, 240, 255, 0.34), transparent 66%);
  pointer-events: none;
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.hero h1 {
  margin: 0 0 10px;
  font-size: clamp(32px, 4vw, 48px);
}

.hero-copy {
  margin: 0;
  max-width: 620px;
  line-height: 1.7;
  color: var(--muted);
}

.hero-badge {
  flex: 0 0 170px;
  padding: 16px 18px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px dashed rgba(180, 83, 9, 0.35);
  border-radius: 18px;
  text-align: center;
}

.hero-badge span {
  display: block;
  font-size: 13px;
  color: var(--muted);
}

.hero-badge strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
  color: var(--accent-dark);
}

body.read-only-mode .hero-badge {
  display: none;
}

body.read-only-mode .sidebar-tools {
  display: none;
}

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

.sidebar,
.content-panel {
  padding: 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.sidebar {
  position: sticky;
  top: 18px;
}

.sidebar-head {
  margin-bottom: 18px;
}

.sidebar-tools {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.sidebar-action {
  width: 100%;
  background: rgba(255, 248, 235, 0.92);
  border-color: rgba(180, 83, 9, 0.22);
  color: var(--accent-dark);
  font-weight: 700;
}

.sidebar-label {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
}

.sidebar-head h2 {
  margin: 0;
  font-size: 28px;
}

.category-nav {
  display: grid;
  gap: 12px;
}

.category-tab {
  width: 100%;
  text-align: left;
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px solid rgba(74, 85, 104, 0.12);
  background: rgba(255, 255, 255, 0.78);
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.category-tab:hover {
  transform: translateX(2px);
  border-color: rgba(180, 83, 9, 0.3);
}

.category-tab.active {
  background: linear-gradient(135deg, rgba(180, 83, 9, 0.95), rgba(139, 61, 7, 0.95));
  color: #fff;
  border-color: transparent;
}

.category-tab strong,
.category-tab span {
  display: block;
}

.category-tab strong {
  font-size: 18px;
}

.category-tab span {
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.5;
  opacity: 0.82;
}

.content-panel {
  min-height: 720px;
  position: relative;
}

.category-card {
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.category-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 14px;
}

.category-title-wrap h2 {
  margin: 0;
  font-size: 22px;
}

.category-title-wrap p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.entry-count {
  flex: 0 0 auto;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(180, 83, 9, 0.12);
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 700;
}

.add-form {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
  padding: 16px;
  background: var(--panel-strong);
  border-radius: 18px;
  border: 1px solid rgba(74, 85, 104, 0.12);
}

.modal-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(31, 41, 51, 0.36);
  border-radius: 22px;
  z-index: 10;
}

.modal-card {
  width: min(760px, 100%);
  max-height: calc(100vh - 120px);
  overflow: auto;
  padding: 18px;
  background: #fffdf7;
  border-radius: 22px;
  box-shadow: 0 24px 60px rgba(31, 41, 51, 0.24);
}

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

.modal-head h3 {
  margin: 0;
  font-size: 22px;
}

.modal-head p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.add-form-grid {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 12px;
}

label {
  display: grid;
  gap: 8px;
}

label span,
.edit-image-panel p {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: #334155;
}

input[type="text"],
textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(74, 85, 104, 0.18);
  background: #fff;
  color: var(--ink);
}

textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.6;
}

.upload-box {
  padding: 10px 12px;
  border: 1px dashed rgba(180, 83, 9, 0.4);
  border-radius: 14px;
  background: rgba(255, 248, 235, 0.8);
}

input[type="file"] {
  width: 100%;
}

.preview-list,
.edit-preview-list,
.edit-image-list,
.entry-images {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
}

.image-card {
  position: relative;
  overflow: hidden;
  border-radius: 16px;
  border: 1px solid rgba(74, 85, 104, 0.14);
  background: #fff;
  padding: 8px;
}

.image-card img {
  display: block;
  width: 100%;
  height: 140px;
  object-fit: contain;
  background: #f8fafc;
  border-radius: 10px;
}

.image-card button {
  position: absolute;
  top: 8px;
  right: 8px;
}

.solid-button,
.ghost-button {
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  cursor: pointer;
  transition: transform 0.16s ease, opacity 0.16s ease, background 0.16s ease;
}

.solid-button:hover,
.ghost-button:hover {
  transform: translateY(-1px);
}

.solid-button {
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.solid-button:hover {
  background: var(--accent-dark);
}

.ghost-button {
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink);
  border: 1px solid rgba(74, 85, 104, 0.16);
}

.ghost-button.danger {
  color: var(--danger);
}

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

.note-entry {
  display: grid;
  align-content: start;
  min-height: 280px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.78);
  border-radius: 18px;
  border: 1px solid rgba(74, 85, 104, 0.14);
}

.add-card {
  display: grid;
  place-items: center;
  min-height: 280px;
  padding: 14px;
  border-radius: 18px;
  border: 1px dashed rgba(180, 83, 9, 0.5);
  background:
    linear-gradient(135deg, rgba(255, 248, 235, 0.92), rgba(249, 238, 219, 0.82));
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.add-card:hover {
  transform: translateY(-2px);
  border-color: rgba(180, 83, 9, 0.8);
  box-shadow: 0 14px 30px rgba(180, 83, 9, 0.12);
}

.add-card-inner {
  text-align: center;
  color: var(--accent-dark);
}

.add-symbol {
  display: block;
  font-size: 72px;
  line-height: 1;
  font-weight: 300;
}

.add-text {
  display: block;
  margin-top: 10px;
  font-size: 18px;
  font-weight: 700;
}

.add-hint {
  display: block;
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
}

.entry-toolbar,
.edit-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.entry-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.entry-time {
  color: var(--muted);
  font-size: 12px;
}

.entry-title {
  margin: 0 0 8px;
  font-size: 26px;
  line-height: 1.4;
}

.entry-text {
  margin: 0 0 12px;
  white-space: pre-wrap;
  line-height: 1.6;
  color: #243746;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.entry-view {
  display: grid;
  align-content: start;
  height: 100%;
}

.entry-images {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: auto;
}

.entry-images .image-card img {
  height: 98px;
  cursor: zoom-in;
}

.mini-button {
  padding: 5px 9px;
  border-radius: 10px;
  font-size: 12px;
}

.mini-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

.lightbox-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.72);
  z-index: 999;
}

.lightbox-card {
  position: relative;
  width: min(1100px, 100%);
  max-height: calc(100vh - 48px);
  padding: 18px;
  border-radius: 22px;
  background: rgba(255, 253, 247, 0.98);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28);
}

.lightbox-toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.lightbox-zoom-label {
  min-width: 54px;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.lightbox-image {
  display: block;
  width: 100%;
  max-height: calc(100vh - 120px);
  object-fit: contain;
  border-radius: 14px;
  background: #f8fafc;
  transform-origin: center center;
  cursor: zoom-in;
  transition: transform 0.08s ease-out;
}

.lightbox-image.pannable {
  cursor: grab;
}

.lightbox-image.dragging {
  cursor: grabbing;
  transition: none;
}

.lightbox-close {
  position: static;
}

.entry-edit {
  display: grid;
  gap: 12px;
}

.hidden {
  display: none;
}

.empty-state {
  padding: 16px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed rgba(74, 85, 104, 0.22);
  border-radius: 16px;
  grid-column: 1 / -1;
}

@media (max-width: 1280px) {
  .entry-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1080px) {
  .entry-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .hero,
  .category-header,
  .entry-toolbar,
  .edit-actions {
    flex-direction: column;
    align-items: stretch;
  }

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

  .sidebar {
    position: static;
  }

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

  .entry-list {
    grid-template-columns: 1fr;
  }

  .hero-badge {
    width: 100%;
  }

  .modal-overlay {
    padding: 14px;
  }
}
