:root {
  color-scheme: light;
  --bg: #ffffff;
  --panel: #ffffff;
  --panel-2: #f5f6f8;
  --panel-3: #eceff3;
  --text: #111318;
  --muted: #69707d;
  --line: #d9dde5;
  --line-soft: rgba(17, 19, 24, 0.08);
  --accent: #111318;
  --accent-hover: #2a2e36;
  --accent-soft: rgba(17, 19, 24, 0.055);
  --positive: #00a875;
  --positive-soft: rgba(0, 168, 117, 0.12);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.1);
  --shadow: 0 16px 42px rgba(17, 19, 24, 0.08);
  --font-sans:
    Inter, "SF Pro Text", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  --font-display:
    "SF Pro Display", Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  --font-number: "DIN Alternate", "Roboto Mono", "SFMono-Regular", Consolas, monospace;
  font-family: var(--font-sans);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.5;
}

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

button,
select {
  cursor: pointer;
}

a {
  color: var(--accent);
}

[hidden] {
  display: none !important;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.ui-icon {
  width: 1em;
  height: 1em;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 56px;
  padding: 8px clamp(12px, 3vw, 28px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 850;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
}

.brand-mark .ui-icon {
  width: 20px;
  height: 20px;
  stroke-width: 2;
}

.topbar-actions,
.dialog-actions,
.comment-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn,
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  padding: 0 12px;
  font-size: 12px;
  font-weight: 800;
  transition:
    background 0.16s ease,
    border-color 0.16s ease,
    color 0.16s ease;
}

.btn .ui-icon {
  width: 14px;
  height: 14px;
}

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

.btn.danger {
  border-color: rgba(239, 68, 68, 0.24);
  background: #fff;
  color: var(--danger);
}

.btn:disabled {
  cursor: default;
  opacity: 0.45;
}

.icon-btn {
  width: 34px;
  padding: 0;
}

.text-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0;
  font-size: 11px;
  font-weight: 800;
}

.text-btn .ui-icon {
  width: 13px;
  height: 13px;
}

.text-btn.danger {
  color: var(--danger);
}

.login-screen {
  display: grid;
  min-height: 100dvh;
  place-items: center;
  padding: 24px;
}

.login-card {
  display: grid;
  width: min(430px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(17, 19, 24, 0.04), transparent 36%),
    var(--panel);
  padding: 12px;
  box-shadow: var(--shadow);
}

.login-content {
  display: grid;
  gap: 18px;
  padding: clamp(18px, 4vw, 34px);
}

.login-content .brand-mark {
  width: 42px;
  height: 42px;
}

.login-content .brand-mark .ui-icon {
  width: 24px;
  height: 24px;
}

.login-content h1 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: clamp(24px, 4vw, 32px);
  font-weight: 850;
  line-height: 1.08;
}

.summary-copy {
  max-width: 640px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.login-submit {
  width: 100%;
  min-height: 42px;
}

.login-message {
  display: flex;
  align-items: center;
  min-height: 34px;
  margin: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 7px 10px;
  color: var(--muted);
  font-size: 12px;
}

.login-message:empty {
  display: none;
}

.login-message[data-type="info"] {
  border-color: var(--line-soft);
  background: #f8f9fb;
}

.login-message[data-type="error"] {
  border-color: rgba(239, 68, 68, 0.2);
  background: var(--danger-soft);
  color: var(--danger);
}

.layout {
  width: min(1580px, 100%);
  margin: 0 auto;
  padding: 10px clamp(10px, 2.4vw, 24px) 32px;
}

.content {
  display: grid;
  grid-template-columns: minmax(230px, 270px) minmax(300px, 370px) minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.side-panel,
.list-panel,
.detail-panel {
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.side-panel,
.list-panel {
  position: sticky;
  top: 66px;
  display: grid;
  max-height: calc(100dvh - 76px);
  overflow: hidden;
}

.side-panel {
  grid-template-rows: auto auto minmax(0, 1fr);
}

.list-panel {
  grid-template-rows: auto minmax(0, 1fr);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  border-bottom: 1px solid var(--line);
  padding: 11px 12px;
}

.panel-kicker {
  margin: 0 0 3px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.panel-head h2,
.section-head h2 {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 850;
}

.panel-title-text .ui-icon,
.section-head .ui-icon {
  color: var(--positive);
}

.panel-count {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid rgba(17, 19, 24, 0.16);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 0 8px;
  white-space: nowrap;
  font-family: var(--font-number);
  font-size: 11px;
  font-weight: 800;
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  border-bottom: 1px solid var(--line-soft);
  padding: 10px;
}

.stat {
  min-height: 52px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #fff;
  padding: 8px;
}

.stat strong {
  display: block;
  color: var(--accent);
  font-family: var(--font-number);
  font-size: 18px;
  line-height: 1;
}

.stat span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
}

label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 0 9px;
  outline: none;
}

textarea {
  min-height: 94px;
  padding: 10px;
  resize: vertical;
  line-height: 1.65;
}

input::placeholder,
textarea::placeholder {
  color: #a1a7b3;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(17, 19, 24, 0.08);
}

.filter-panel {
  display: grid;
  align-content: start;
  gap: 10px;
  overflow: auto;
  padding: 12px;
}

.thought-list {
  display: grid;
  align-content: start;
  overflow: auto;
}

.thought-card {
  display: grid;
  gap: 7px;
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  background: transparent;
  color: inherit;
  padding: 12px;
  text-align: left;
}

.thought-card:last-child {
  border-bottom: 0;
}

.thought-card.is-active {
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--positive);
}

.thought-card-top,
.card-foot,
.comment-head,
.section-head,
.article-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.thought-card-top,
.card-foot,
.section-head {
  justify-content: space-between;
}

.thought-date {
  color: var(--text);
  font-family: var(--font-number);
  font-size: 12px;
  font-weight: 850;
}

.status-pill,
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 21px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  padding: 0 7px;
  font-size: 11px;
  font-weight: 800;
}

.pill.accent {
  border-color: rgba(0, 168, 117, 0.28);
  background: var(--positive-soft);
  color: var(--positive);
}

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

.thought-card h3 {
  margin: 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 850;
  line-height: 1.35;
}

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

.card-foot {
  color: var(--muted);
  font-family: var(--font-number);
  font-size: 11px;
  font-weight: 800;
}

.card-foot span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.detail-panel {
  min-height: calc(100dvh - 76px);
  overflow: hidden;
}

.empty-detail,
.empty-state {
  display: grid;
  place-items: center;
  min-height: 280px;
  padding: 36px 18px;
  color: var(--muted);
  text-align: center;
}

.empty-detail {
  align-content: center;
  gap: 12px;
}

.empty-detail h1 {
  max-width: 520px;
  margin: 0;
  color: var(--text);
  font-family: var(--font-display);
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1.18;
}

.empty-detail p {
  max-width: 560px;
  margin: 0;
}

.article-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line-soft);
  padding: 24px clamp(16px, 2.6vw, 34px) 18px;
}

.article-head h1 {
  max-width: 860px;
  margin: 0;
  color: var(--text);
  font-family: var(--font-display);
  font-size: clamp(25px, 3.5vw, 44px);
  font-weight: 850;
  line-height: 1.12;
  letter-spacing: 0;
}

.article-meta {
  flex-wrap: wrap;
  margin-top: 10px;
  color: var(--muted);
  font-family: var(--font-number);
  font-size: 12px;
  font-weight: 800;
}

.article-meta span:not(:last-child)::after {
  content: "/";
  margin-left: 8px;
  color: #c0c5ce;
}

.article-summary {
  margin: 0;
  border-bottom: 1px solid var(--line-soft);
  background: #fafbfc;
  color: var(--text);
  padding: 16px clamp(16px, 2.6vw, 34px);
  font-size: 15px;
  line-height: 1.7;
}

.article-tags {
  padding: 14px clamp(16px, 2.6vw, 34px) 0;
}

.article-body {
  max-width: 920px;
  padding: 18px clamp(16px, 2.6vw, 34px) 30px;
}

.article-body h2,
.article-body h3,
.article-body h4 {
  margin: 1.5em 0 0.55em;
  color: var(--text);
  font-family: var(--font-display);
  line-height: 1.25;
}

.article-body h2 {
  font-size: 22px;
}

.article-body h3 {
  font-size: 18px;
}

.article-body h4 {
  font-size: 15px;
}

.article-body p,
.article-body li,
.article-body blockquote {
  color: #262b34;
  font-size: 15px;
  line-height: 1.85;
}

.article-body p {
  margin: 0 0 1em;
}

.article-body ul {
  margin: 0 0 1em;
  padding-left: 1.35em;
}

.article-body blockquote {
  margin: 1em 0;
  border-left: 3px solid var(--positive);
  background: #f8faf9;
  padding: 10px 14px;
}

.md-image {
  margin: 18px 0;
}

.md-image img {
  display: block;
  max-width: 100%;
  max-height: 72dvh;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #fff;
  object-fit: contain;
}

.md-image figcaption {
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.md-image figcaption:empty {
  display: none;
}

.article-body code,
.comment-body code {
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: #f7f8fa;
  padding: 1px 5px;
  font-family: var(--font-number);
  font-size: 0.92em;
}

.article-body pre,
.comment-body pre {
  overflow: auto;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #111318;
  color: #f5f6f8;
  padding: 14px;
}

.article-body pre code,
.comment-body pre code {
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
}

.comment-panel {
  border-top: 1px solid var(--line);
  background: #fbfcfd;
  padding: 18px clamp(16px, 2.6vw, 34px) 28px;
}

.comment-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.comment {
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.comment-head {
  justify-content: space-between;
  color: var(--muted);
  font-family: var(--font-number);
  font-size: 11px;
  font-weight: 800;
}

.comment-body {
  margin-top: 8px;
}

.comment-body p,
.empty-copy {
  margin: 0;
  color: #343a46;
  line-height: 1.7;
}

.comment-form {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.comment-form textarea {
  min-height: 86px;
}

.comment-actions {
  justify-content: space-between;
}

.status-text {
  min-height: 24px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.dialog {
  width: min(940px, calc(100% - 24px));
  max-height: calc(100dvh - 28px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  padding: 0;
  box-shadow: var(--shadow);
}

.dialog::backdrop {
  background: rgba(17, 19, 24, 0.32);
  backdrop-filter: blur(4px);
}

.dialog form {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.dialog-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line-soft);
  padding-bottom: 14px;
}

.dialog-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 22px;
  line-height: 1.2;
}

.form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(150px, 190px) minmax(130px, 160px);
  gap: 10px;
}

.summary-input {
  min-height: 72px;
}

#contentInput {
  min-height: min(48dvh, 460px);
  font-size: 14px;
}

.dialog-actions {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
}

@media (hover: hover) {
  .btn:hover,
  .icon-btn:hover {
    border-color: #b7beca;
    background: var(--panel-3);
  }

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

  .btn.danger:hover {
    border-color: rgba(239, 68, 68, 0.34);
    background: var(--danger-soft);
  }

  .thought-card:hover {
    background: #f7f8fa;
  }
}

@media (max-width: 1180px) {
  .content {
    grid-template-columns: minmax(260px, 330px) minmax(0, 1fr);
  }

  .side-panel {
    position: static;
    grid-column: 1 / -1;
    max-height: none;
  }

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

  .filter-panel {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .content,
  .filter-panel,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .side-panel,
  .list-panel {
    position: static;
    max-height: none;
  }

  .thought-list {
    max-height: 42dvh;
  }

  .article-head,
  .comment-actions,
  .dialog-actions {
    align-items: stretch;
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .article-head .btn,
  .comment-actions .btn,
  .dialog-actions .btn {
    width: 100%;
  }
}

@media (max-width: 620px) {
  body {
    font-size: 13px;
  }

  .topbar {
    position: static;
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 10px 12px;
  }

  .brand,
  .topbar-actions {
    width: 100%;
  }

  .topbar-actions .btn {
    width: 100%;
    min-height: 40px;
  }

  .layout {
    padding: 10px 10px 24px;
  }

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

  .article-head,
  .article-summary,
  .article-tags,
  .article-body,
  .comment-panel {
    padding-left: 14px;
    padding-right: 14px;
  }

  .article-head h1 {
    font-size: 26px;
  }

  .btn,
  input,
  select {
    min-height: 40px;
  }

  input,
  select,
  textarea {
    font-size: 16px;
  }

  .login-screen {
    align-items: start;
    padding: 18px 12px;
  }

  .login-card {
    margin-top: 10vh;
    padding: 20px;
  }

  .login-content {
    padding: 0;
  }
}
