/* ---------------------------------------------------------
   随想 · 纯白极简
   --------------------------------------------------------- */

:root {
  --bg: #ffffff;
  --text: #1a1a1a;
  --text-2: #5c5c5c;
  --text-3: #9a9a9a;
  --line: #ececec;
  --line-strong: #dedede;
  --hover: #f6f6f6;
  --danger: #b42318;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  scrollbar-width: thin;
  scrollbar-color: #d2d2d2 #ffffff;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

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

button {
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

::selection {
  background: #e8e8e8;
}

:focus-visible {
  outline: 2px solid #111;
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.icon {
  display: block;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------------------------------------------------------
   顶栏
   --------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  max-width: 708px;
  height: 64px;
  margin: 0 auto;
  padding: 0 24px;
}

.brand {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.12em;
  line-height: 1;
}

.today {
  font-size: 12.5px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.account-btn {
  flex: none;
  font-size: 12.5px;
  color: var(--text-3);
  white-space: nowrap;
  transition: color 0.15s ease;
}

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

.account-btn.is-error {
  color: var(--danger);
}

.search {
  position: relative;
  width: 216px;
}

.search-icon {
  position: absolute;
  top: 50%;
  left: 10px;
  width: 14px;
  height: 14px;
  color: #adadad;
  transform: translateY(-50%);
  pointer-events: none;
}

.search input {
  width: 100%;
  height: 34px;
  padding: 0 30px 0 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  background: var(--bg);
  font-size: 13px;
  line-height: 34px;
  transition: border-color 0.15s ease;
}

.search input::placeholder {
  color: #b3b3b3;
}

.search input:focus {
  border-color: #111;
}

.search input::-webkit-search-cancel-button,
.search input::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
}

.search-clear {
  position: absolute;
  top: 50%;
  right: 6px;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  color: #9a9a9a;
  transform: translateY(-50%);
}

.search-clear:hover {
  background: var(--hover);
  color: var(--text);
}

.search-clear .icon {
  width: 13px;
  height: 13px;
}

/* ---------------------------------------------------------
   主体
   --------------------------------------------------------- */

.main {
  display: flex;
  flex: 1;
  padding: 44px 24px 72px;
}

.shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 660px;
  margin: 0 auto;
}

/* ---------------------------------------------------------
   撰写
   --------------------------------------------------------- */

.composer {
  padding: 16px 16px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--bg);
  transition: border-color 0.15s ease;
}

.composer:focus-within {
  border-color: #111;
}

.composer textarea {
  display: block;
  width: 100%;
  min-height: 88px;
  max-height: 360px;
  padding: 0;
  border: 0;
  outline: none;
  background: transparent;
  resize: none;
  font-size: 16px;
  line-height: 1.85;
  color: var(--text);
  scrollbar-width: thin;
  scrollbar-color: #d8d8d8 transparent;
}

.composer textarea::-webkit-scrollbar {
  width: 6px;
}

.composer textarea::-webkit-scrollbar-thumb {
  border-radius: 3px;
  background: #dcdcdc;
}

.composer textarea:focus-visible {
  outline: none;
}

.composer textarea::placeholder {
  color: #b5b5b5;
}

.composer-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 34px;
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.draft-hint {
  font-size: 12px;
  color: var(--text-3);
}

.draft-hint button {
  margin-left: 6px;
  color: var(--text-2);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.draft-hint button:hover {
  color: var(--text);
}

.char-count {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.btn-primary {
  height: 34px;
  padding: 0 16px;
  border-radius: 7px;
  background: #111;
  color: #fff;
  font-size: 13px;
  letter-spacing: 0.02em;
  transition: background 0.15s ease, opacity 0.15s ease;
}

.btn-primary:hover:not(:disabled) {
  background: #333;
}

.btn-primary:disabled {
  background: #f1f1f1;
  color: #b3b3b3;
  cursor: default;
}

/* ---------------------------------------------------------
   时间轴
   --------------------------------------------------------- */

.feed {
  flex: 1;
}

.feed-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 38px 0 4px;
}

.feed-head h2 {
  margin: 0;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.feed-count {
  font-size: 12.5px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.day {
  margin-top: 26px;
}

.day-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.day-title {
  font-size: 13px;
  font-weight: 600;
}

.day-meta {
  font-size: 12px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.entry {
  position: relative;
  padding: 15px 0 16px;
  border-bottom: 1px solid #f4f4f4;
}

.entry:last-child {
  border-bottom: 0;
}

.entry-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 18px;
}

.entry-time {
  font-size: 12px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.entry-edited {
  font-size: 11.5px;
  color: #b3b3b3;
}

.entry-actions {
  display: flex;
  gap: 14px;
  margin-left: auto;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.entry:hover .entry-actions,
.entry:focus-within .entry-actions,
.entry.is-editing .entry-actions {
  opacity: 1;
}

.entry-action {
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-3);
}

.entry-action:hover {
  color: var(--text);
}

.entry-action.is-danger:hover {
  color: var(--danger);
}

.entry-action.is-save {
  color: var(--text);
  font-weight: 600;
}

.entry-body {
  margin-top: 4px;
  font-size: 15.5px;
  line-height: 1.9;
  color: #202020;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.entry-body mark {
  padding: 0 1px;
  border-radius: 2px;
  background: #ededed;
  color: inherit;
}

.edit-area {
  display: block;
  width: 100%;
  min-height: 104px;
  max-height: 420px;
  margin-top: 4px;
  padding: 0;
  border: 0;
  border-radius: 0;
  outline: none;
  background: transparent;
  resize: none;
  font-size: 15.5px;
  line-height: 1.9;
  color: var(--text);
  scrollbar-width: thin;
  scrollbar-color: #d8d8d8 transparent;
}

.edit-area::-webkit-scrollbar {
  width: 6px;
}

.edit-area::-webkit-scrollbar-thumb {
  border-radius: 3px;
  background: #dcdcdc;
}

.edit-area::-webkit-scrollbar-track {
  background: transparent;
}

.edit-area:focus,
.edit-area:focus-visible {
  border: 0;
  outline: none;
}

/* ---------------------------------------------------------
   空状态
   --------------------------------------------------------- */

.empty {
  padding: 46px 0 34px;
  text-align: center;
}

.empty h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
}

.empty p {
  margin: 7px 0 0;
  font-size: 13px;
  color: var(--text-3);
}

.empty button {
  margin-top: 14px;
  font-size: 12.5px;
  color: var(--text-2);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.empty button:hover {
  color: var(--text);
}

/* ---------------------------------------------------------
   页脚
   --------------------------------------------------------- */

.site-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 52px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--text-3);
}

.foot-actions {
  display: flex;
  gap: 14px;
  margin-left: auto;
}

.foot-actions button {
  font-size: 12px;
  color: var(--text-2);
}

.foot-actions button:hover {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ---------------------------------------------------------
   提示
   --------------------------------------------------------- */

.toast-stack {
  position: fixed;
  bottom: calc(26px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: calc(100vw - 32px);
  padding: 9px 14px;
  border-radius: 8px;
  background: #111;
  color: #fff;
  font-size: 12.5px;
  line-height: 1.5;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.14);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: auto;
}

.toast.in {
  opacity: 1;
  transform: none;
}

.toast button {
  flex: none;
  color: #fff;
  font-size: 12.5px;
  text-decoration: underline;
  text-underline-offset: 2px;
  white-space: nowrap;
}

/* ---------------------------------------------------------
   登录 / 同步弹窗
   --------------------------------------------------------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(17, 17, 17, 0.32);
}

.modal[hidden] {
  display: none;
}

.modal-card {
  position: relative;
  width: 100%;
  max-width: 392px;
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  padding: 26px 26px 22px;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.18);
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  color: var(--text-3);
}

.modal-close:hover {
  background: var(--hover);
  color: var(--text);
}

.modal-close .icon {
  width: 15px;
  height: 15px;
}

.modal h2 {
  margin: 0 0 6px;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.modal-lead {
  margin: 0 0 20px;
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--text-3);
}

.auth-field {
  display: block;
  margin-bottom: 14px;
  font-size: 12px;
  color: var(--text-2);
}

.auth-field input {
  display: block;
  width: 100%;
  height: 38px;
  margin-top: 6px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  outline: none;
  background: #fff;
  font-size: 14px;
  color: var(--text);
  transition: border-color 0.15s ease;
}

.auth-field input:focus {
  border-color: #111;
}

.auth-error {
  margin: 0 0 12px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--danger);
}

.auth-error.is-info {
  color: var(--text-2);
}

.auth-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 4px;
}

.auth-actions .btn-primary {
  height: 36px;
  padding: 0 18px;
  font-size: 13px;
}

.link-btn {
  font-size: 12.5px;
  color: var(--text-3);
  text-decoration: underline;
  text-underline-offset: 2px;
}

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

.sync-email {
  margin: 0 0 4px;
  font-size: 13px;
  color: var(--text);
  overflow-wrap: anywhere;
}

.sync-status {
  min-height: 18px;
  margin: 0 0 18px;
  font-size: 12px;
  color: var(--text-3);
}

.sync-status.is-error {
  color: var(--danger);
}

.sync-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.btn-secondary {
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fff;
  font-size: 12.5px;
  color: var(--text);
  transition: border-color 0.15s ease;
}

.btn-secondary:hover {
  border-color: #111;
}

.modal-foot {
  margin: 20px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  line-height: 1.7;
  color: var(--text-3);
}

.noscript {
  padding: 20px 24px;
  text-align: center;
  font-size: 13px;
  color: var(--text-2);
}

/* ---------------------------------------------------------
   响应式
   --------------------------------------------------------- */

@media (max-width: 640px) {
  .topbar-inner {
    flex-wrap: wrap;
    gap: 10px;
    height: auto;
    padding: 14px 18px 12px;
  }

  .today {
    display: none;
  }

  .top-actions {
    display: contents;
  }

  .account-btn {
    order: 2;
    margin-left: auto;
  }

  .search {
    order: 3;
    width: 100%;
    margin-left: 0;
  }

  .search input {
    height: 36px;
    font-size: 16px;
    line-height: 36px;
  }

  .main {
    padding: 26px 18px 60px;
  }

  .composer {
    padding: 14px 14px 10px;
  }

  .composer textarea {
    min-height: 76px;
  }

  .entry {
    padding: 14px 0 15px;
  }

  .entry-actions {
    opacity: 1;
    gap: 16px;
  }

  .entry-action {
    padding: 2px 0;
    font-size: 13px;
  }

  .edit-area {
    font-size: 16px;
  }

  .foot-actions button {
    padding: 4px 0;
  }

  .entry-body {
    font-size: 15px;
    line-height: 1.85;
  }

  .empty {
    padding: 56px 0 40px;
  }

  .site-foot {
    margin-top: 40px;
  }

  .modal-card {
    padding: 24px 20px 20px;
  }

  .auth-field input {
    font-size: 16px;
  }
}

@media (max-width: 380px) {
  .char-count {
    display: none;
  }

  .composer-foot .btn-primary {
    margin-left: auto;
  }
}

@media (hover: none) {
  .entry-actions {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
