:root {
  color-scheme: light;
  --bg: #f6f3ed;
  --surface: #ffffff;
  --surface-2: #fbf8f1;
  --surface-3: #efe8dc;
  --text: #1a1814;
  --body: #3d3a34;
  --muted: #7b7266;
  --line: #e8e2d9;
  --line-strong: #d9cfc1;
  --accent: #b8862e;
  --accent-2: #4a6fa5;
  --danger: #b05050;
  --success: #5a8c5a;
  --shadow: 0 10px 26px rgba(82, 63, 38, 0.08), 0 1px 0 rgba(255, 255, 255, 0.75) inset;
  --paper-shadow: 0 18px 42px rgba(82, 63, 38, 0.12);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #1c1a17;
    --surface: #2c2925;
    --surface-2: #24211e;
    --surface-3: #37322d;
    --text: #ede9e0;
    --body: #c8c3b8;
    --muted: #9f978b;
    --line: #3d3833;
    --line-strong: #524b43;
    --accent: #d4a24a;
    --accent-2: #6b8fbe;
    --danger: #c06060;
    --success: #6fa06f;
    --shadow: 0 12px 28px rgba(0, 0, 0, 0.22), 0 1px 0 rgba(255, 255, 255, 0.04) inset;
    --paper-shadow: 0 22px 48px rgba(0, 0, 0, 0.32);
  }
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--body);
  background:
    radial-gradient(circle at 12px 18px, rgba(120, 95, 58, 0.035) 0 1px, transparent 1.5px),
    radial-gradient(circle at 72px 62px, rgba(120, 95, 58, 0.025) 0 1px, transparent 1.5px),
    var(--bg);
  background-size: 96px 96px, 118px 118px, auto;
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.8;
}

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

button {
  cursor: pointer;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: min(100%, 460px);
  min-height: 64px;
  margin: 0 auto;
  padding: 12px 24px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 94%, transparent);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--accent);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  overflow: hidden;
  color: var(--text);
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: 16px;
  line-height: 1.35;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.brand span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.nav {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.nav a,
.nickname-btn,
.nickname-text {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  padding: 8px 9px;
  text-decoration: none;
  white-space: nowrap;
}

.nickname-control {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.nickname-text {
  display: inline-flex;
  align-items: center;
  max-width: 112px;
  overflow: hidden;
  color: var(--text);
  font-weight: 700;
  text-overflow: ellipsis;
}

.nav a:hover,
.nickname-btn:hover {
  background: var(--surface-3);
  color: var(--text);
}

main {
  width: min(100%, 460px);
  margin: 0 auto;
  padding: 24px 24px 72px;
}

.hero {
  display: grid;
  gap: 22px;
  padding: 24px 0 22px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  color: var(--text);
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-weight: 800;
}

h1 {
  margin-bottom: 16px;
  font-size: 34px;
  line-height: 1.18;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 25px;
  line-height: 1.3;
}

h3 {
  font-size: 18px;
  line-height: 1.45;
}

.hero-copy {
  margin-bottom: 0;
  color: var(--body);
  font-size: 15px;
  line-height: 1.9;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.stats div {
  min-height: 76px;
  padding: 13px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.stats strong,
.stats span {
  display: block;
}

.stats strong {
  color: var(--text);
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: 25px;
  line-height: 1.2;
}

.stats span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.workspace {
  display: grid;
  gap: 16px;
  align-items: start;
}

.panel,
.feed,
.admin-area {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--paper-shadow);
}

.forms {
  padding: 16px;
}

.tabs,
.segmented {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  overflow-x: auto;
}

.tabs {
  margin-bottom: 16px;
}

.tab,
.segmented button,
.ghost {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  padding: 8px 11px;
  white-space: nowrap;
}

.tab.active,
.segmented button.active {
  border-left: 3px solid var(--accent);
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
  box-shadow: var(--shadow);
}

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

label {
  display: grid;
  gap: 7px;
  color: var(--body);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  padding: 10px 12px;
  outline: none;
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.primary {
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fffaf0;
  padding: 11px 14px;
  font-weight: 800;
}

.primary:hover {
  filter: brightness(0.96);
}

.feed {
  min-height: 420px;
  overflow: hidden;
}

.feed-toolbar {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.cards {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 15px;
  box-shadow: var(--shadow);
  animation: fadeIn 250ms ease both;
}

.card-head {
  display: grid;
  gap: 10px;
}

.card-head > div:first-child {
  min-width: 0;
}

.card h3 {
  margin-bottom: 6px;
  overflow-wrap: anywhere;
}

.meta,
.card-body,
.reply,
.comment {
  color: var(--body);
  line-height: 1.85;
}

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

.card-body {
  white-space: pre-wrap;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.badge.status-published,
.badge.status-accepted,
.badge.status-done {
  border-color: color-mix(in srgb, var(--success) 35%, var(--line));
  background: color-mix(in srgb, var(--success) 12%, var(--surface));
  color: var(--success);
}

.badge.status-open {
  border-color: color-mix(in srgb, var(--accent-2) 32%, var(--line));
  background: color-mix(in srgb, var(--accent-2) 10%, var(--surface));
  color: var(--accent-2);
}

.badge.status-reviewing,
.badge.status-planned {
  border-color: color-mix(in srgb, var(--accent) 38%, var(--line));
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  color: var(--accent);
}

.badge.status-rejected,
.badge.status-closed {
  border-color: color-mix(in srgb, var(--danger) 34%, var(--line));
  background: color-mix(in srgb, var(--danger) 10%, var(--surface));
  color: var(--danger);
}

.actions,
.owner-card-tools,
.comment-tools,
.comment-edit-form,
.admin-head-actions,
.admin-card-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.actions,
.owner-card-tools {
  margin-top: 14px;
}

.action-btn,
.danger {
  min-height: 40px;
  border-radius: 6px;
  padding: 8px 11px;
}

.action-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--body);
}

.action-btn:hover,
.ghost:hover {
  border-color: var(--line-strong);
  background: var(--surface-2);
  color: var(--text);
}

.action-btn:disabled {
  cursor: not-allowed;
  background: var(--surface-2);
  color: var(--muted);
}

.danger {
  border: 1px solid color-mix(in srgb, var(--danger) 38%, var(--line));
  background: color-mix(in srgb, var(--danger) 9%, var(--surface));
  color: var(--danger);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 40px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--body);
  padding: 8px 10px;
  line-height: 1;
}

.icon-btn:hover {
  border-color: var(--line-strong);
  background: var(--surface-2);
  color: var(--text);
}

.icon-btn.danger {
  border-color: color-mix(in srgb, var(--danger) 38%, var(--line));
  background: color-mix(in srgb, var(--danger) 9%, var(--surface));
  color: var(--danger);
}

.icon-btn.liked {
  border-color: color-mix(in srgb, var(--danger) 40%, var(--line));
  color: var(--danger);
}

.icon-symbol {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  font-size: 16px;
  line-height: 1;
}

.icon-count {
  min-width: 1ch;
  color: inherit;
  font-size: 12px;
  line-height: 1;
}

.image-preview {
  display: block;
  width: 100%;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-2);
}

.image-preview img {
  display: block;
  width: 100%;
  max-height: 300px;
  object-fit: contain;
}

.comment-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 12px;
}

.reply,
.comments {
  margin-top: 13px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
}

.reply {
  color: var(--body);
}

.comment {
  margin-top: 9px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.comment-text {
  overflow-wrap: anywhere;
}

.comment-tools,
.comment-edit-form {
  margin-top: 8px;
}

.comment-edit-form input[name="content"] {
  flex: 1 1 100%;
}

.admin-area {
  margin-top: 18px;
  padding: 16px;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.login-form {
  display: grid;
  gap: 10px;
}

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

.char-hint {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.char-hint.over-limit {
  color: var(--danger);
  font-weight: 700;
}

.admin-board {
  display: grid;
  gap: 12px;
}

.admin-toolbar {
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.admin-cards {
  padding: 0;
}

.admin-card-tools {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.admin-status-select {
  width: auto;
  min-width: 136px;
}

.admin-edit-form,
.owner-edit-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(380px, calc(100vw - 36px));
  transform: translateY(16px);
  opacity: 0;
  pointer-events: none;
  border-radius: 8px;
  background: var(--text);
  color: var(--surface);
  padding: 12px 14px;
  transition: opacity 250ms ease, transform 250ms ease;
  box-shadow: var(--paper-shadow);
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.nickname-dialog {
  width: min(420px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--body);
  box-shadow: var(--paper-shadow);
  padding: 0;
}

.nickname-dialog::backdrop {
  background: rgba(26, 24, 20, 0.34);
}

.nickname-dialog form {
  display: grid;
  gap: 12px;
  padding: 20px;
}

.nickname-dialog h2 {
  font-size: 24px;
}

.hidden {
  display: none !important;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (min-width: 760px) {
  .feed-toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .feed-toolbar .segmented,
  .feed-toolbar input {
    grid-column: 1 / -1;
  }

  .login-form {
    grid-template-columns: 1fr 150px 150px;
  }

  .login-form .hint {
    grid-column: 1 / -1;
  }

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

@media (min-width: 1120px) {
  .topbar,
  main {
    width: min(100%, 1120px);
  }

  .topbar {
    padding-right: 32px;
    padding-left: 32px;
  }

  main {
    padding-right: 32px;
    padding-left: 32px;
  }

  .hero {
    grid-template-columns: minmax(0, 1fr) 360px;
    align-items: end;
    padding-top: 34px;
  }

  h1 {
    max-width: 680px;
    font-size: 42px;
  }

  .hero-copy {
    max-width: 620px;
  }

  .workspace {
    grid-template-columns: 340px minmax(0, 1fr);
    gap: 20px;
  }

  .forms {
    position: sticky;
    top: 86px;
  }

  .feed-toolbar {
    grid-template-columns: minmax(360px, 1fr) 150px 150px;
    align-items: start;
  }

  .feed-toolbar .segmented {
    grid-column: auto;
  }

  .feed-toolbar input {
    grid-column: 1 / -1;
  }

  .card {
    padding: 18px;
  }

  .card-head {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
  }

  .badges {
    justify-content: flex-end;
    max-width: 270px;
  }

  .admin-area {
    padding: 20px;
  }

  .admin-toolbar {
    grid-template-columns: minmax(360px, 1fr) 150px 150px;
  }

  .admin-edit-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-edit-form label:has(textarea),
  .admin-edit-form .actions {
    grid-column: 1 / -1;
  }
}

@media (max-width: 620px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .nav {
    width: 100%;
  }

  .nav a,
  .nickname-btn,
  .nickname-text {
    min-width: max-content;
  }

  h1 {
    font-size: 31px;
  }
}
