: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: #00c087;
  --positive-soft: rgba(0, 192, 135, 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,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

[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;
  font-weight: 900;
}

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

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

.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;
}

.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;
  color: var(--text);
  font-family: var(--font-display);
  font-size: clamp(24px, 4vw, 32px);
  font-weight: 850;
  line-height: 1.08;
}

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

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

.login-submit.loading {
  cursor: wait;
  opacity: 0.82;
}

.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;
  color: var(--muted);
}

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

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

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

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

.list-panel {
  position: sticky;
  top: 66px;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  max-height: calc(100dvh - 76px);
  overflow: hidden;
}

.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,
.detail-head h1 {
  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,
.detail-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;
}

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

input,
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: calc(100dvh - 260px);
  resize: none;
  padding: 12px;
  font-size: 15px;
  line-height: 1.7;
}

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

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

.search-box {
  border-bottom: 1px solid var(--line-soft);
  padding: 12px;
}

.month-index {
  display: grid;
  align-content: start;
  overflow: auto;
}

.month-group {
  border-bottom: 1px solid var(--line-soft);
  background: transparent;
}

.month-group:last-child {
  border-bottom: 0;
}

.month-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 11px 12px;
  text-align: left;
}

.month-toggle span:first-child {
  font-weight: 850;
}

.month-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.month-caret {
  display: inline-grid;
  place-items: center;
  width: 16px;
  color: var(--positive);
  font-family: var(--font-number);
  font-size: 11px;
  line-height: 1;
}

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

.story-list {
  display: grid;
}

.story-link {
  display: grid;
  gap: 6px;
  width: 100%;
  min-height: 58px;
  border: 0;
  border-top: 1px solid var(--line-soft);
  background: transparent;
  color: inherit;
  padding: 12px;
  text-align: left;
  transition:
    background 0.16s ease,
    box-shadow 0.16s ease;
}

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

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

.story-excerpt {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.story-form {
  display: grid;
  gap: 16px;
  height: 100%;
  padding: 22px clamp(16px, 2.6vw, 30px);
}

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

.detail-head h1 {
  font-size: clamp(20px, 2.4vw, 28px);
  line-height: 1.28;
}

.status-text {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  margin: 0;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: #f8f9fb;
  color: var(--muted);
  padding: 0 10px;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
}

.form-topline {
  display: grid;
  grid-template-columns: minmax(180px, 260px) auto;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}

.keyword-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 22px;
}

.keyword-pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border: 1px solid rgba(0, 192, 135, 0.28);
  border-radius: 999px;
  background: var(--positive-soft);
  color: var(--positive);
  padding: 0 8px;
  font-size: 11px;
  font-weight: 850;
}

.empty-state {
  padding: 36px 18px;
  color: var(--muted);
  text-align: center;
}

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

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

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

  .month-toggle:hover,
  .story-link:hover {
    background: #f7f8fa;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
  }
}

@media (max-width: 920px) {
  .content {
    grid-template-columns: 1fr;
  }

  .list-panel {
    position: static;
    order: 2;
    max-height: none;
  }

  .detail-panel {
    order: 1;
    min-height: auto;
  }

  .month-index {
    overflow: visible;
  }

  textarea {
    min-height: 44dvh;
  }
}

@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;
  }

  .story-form {
    gap: 14px;
    padding: 14px;
  }

  .detail-head,
  .form-topline,
  .form-actions {
    align-items: stretch;
    grid-template-columns: 1fr;
    flex-direction: column;
  }

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

  .btn {
    min-height: 40px;
  }

  textarea {
    min-height: 48dvh;
    font-size: 16px;
  }

  input {
    font-size: 16px;
  }

  .panel-head {
    padding: 10px 12px;
  }

  .story-link {
    min-height: 62px;
  }

  .status-text {
    justify-content: center;
    width: fit-content;
  }

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

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

  .login-content {
    padding: 0;
  }
}
