:root {
  color-scheme: light;
  --line: #e8e2d8;
  --text: #23201b;
  --muted: #837a6c;
  --accent: #2f6bff;
  --accent-soft: #eef4ff;
  --accent-text: #1b4fd8;
  --warn-soft: #ffeae6;
  --warn-text: #b23a2c;
  --ok: #1f8a52;
  --card: #ffffff;
}

:root[data-theme="orange"] {
  --line: #f0e0cc;
  --accent: #ef8a3a;
  --accent-soft: #fff2e6;
  --accent-text: #bd5c11;
}

:root[data-theme="green"] {
  --line: #d9e9dc;
  --accent: #33a06a;
  --accent-soft: #e9f8ef;
  --accent-text: #1e7a4c;
}

:root[data-theme="purple"] {
  --line: #e3dbf2;
  --accent: #8a6cf0;
  --accent-soft: #f1ecff;
  --accent-text: #6443d6;
}

:root[data-theme="pink"] {
  --line: #f3dae5;
  --accent: #e8709c;
  --accent-soft: #ffeef4;
  --accent-text: #c54a77;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at 8% -12%, rgba(255, 232, 192, 0.55) 0, transparent 44%),
    radial-gradient(circle at 104% 2%, rgba(200, 224, 255, 0.5) 0, transparent 42%),
    linear-gradient(170deg, #ffffff 0%, #faf8f5 46%, #f3f0eb 100%);
  color: var(--text);
}

:root[data-theme="orange"] body {
  background:
    radial-gradient(circle at 8% -12%, rgba(255, 209, 160, 0.6) 0, transparent 44%),
    radial-gradient(circle at 104% 2%, rgba(255, 233, 196, 0.55) 0, transparent 42%),
    linear-gradient(170deg, #fffefc 0%, #fdf7ef 46%, #f9efe3 100%);
}

:root[data-theme="green"] body {
  background:
    radial-gradient(circle at 8% -12%, rgba(186, 240, 205, 0.6) 0, transparent 44%),
    radial-gradient(circle at 104% 2%, rgba(198, 240, 231, 0.55) 0, transparent 42%),
    linear-gradient(170deg, #ffffff 0%, #f4fbf6 46%, #eaf7ef 100%);
}

:root[data-theme="purple"] body {
  background:
    radial-gradient(circle at 8% -12%, rgba(220, 206, 255, 0.6) 0, transparent 44%),
    radial-gradient(circle at 104% 2%, rgba(232, 216, 255, 0.5) 0, transparent 42%),
    linear-gradient(170deg, #ffffff 0%, #f8f5ff 46%, #f0ebfc 100%);
}

:root[data-theme="pink"] body {
  background:
    radial-gradient(circle at 8% -12%, rgba(255, 206, 224, 0.6) 0, transparent 44%),
    radial-gradient(circle at 104% 2%, rgba(255, 222, 234, 0.5) 0, transparent 42%),
    linear-gradient(170deg, #ffffff 0%, #fff5f8 46%, #fdeef4 100%);
}

.app {
  display: flex;
  flex-direction: column;
  width: min(100%, 680px);
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 10px 12px calc(14px + env(safe-area-inset-bottom));
}

.view {
  display: flex;
  flex-direction: column;
}

.view.is-hidden {
  display: none;
}

#sendView {
  flex: 1 1 auto;
  min-height: 0;
}

input,
textarea,
button {
  font: inherit;
}

button {
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 700;
}

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

button.ghost {
  background: var(--accent-soft);
  color: var(--accent-text);
}

button.warn {
  background: var(--warn-soft);
  color: var(--warn-text);
}

.mini-btn {
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 13px;
  white-space: nowrap;
}

.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  box-shadow: 0 6px 20px rgba(70, 60, 40, 0.06);
}

.topbar input {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 8px 11px;
  font-size: 14px;
  background: #fbfaf8;
  color: var(--text);
}

.topbar-title {
  flex: 1 1 auto;
  min-width: 0;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
}

/* 顶栏中间的两段式切换（今天的记录 / 收藏） */
.tab-switch {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 3px;
  border-radius: 11px;
  background: #f4f1ec;
}

.tab-btn {
  padding: 6px 9px;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.tab-btn.is-active {
  background: var(--card);
  color: var(--accent-text);
  box-shadow: 0 2px 6px rgba(70, 60, 40, 0.1);
}

.badge {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.badge-offline {
  background: var(--warn-soft);
  color: var(--warn-text);
}

.badge-online {
  background: #e3f8ec;
  color: var(--ok);
}

.badge-ghost {
  background: #f1ede6;
  color: #6b6155;
}

.tool-row {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
}

.batch-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

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

textarea {
  flex: 1 1 auto;
  width: 100%;
  min-height: 96px;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 13px 14px;
  font-size: 16px;
  line-height: 1.55;
  background: var(--card);
  color: var(--text);
  resize: none;
  box-shadow: 0 6px 20px rgba(70, 60, 40, 0.05);
}

.block {
  flex: 0 0 auto;
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 15px;
  font-size: 16px;
}

.row-4 {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 8px;
}

.row-4 button {
  padding: 12px 4px;
  font-size: 14px;
}

.theme-row {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  padding: 0 2px;
}

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

.theme-swatches {
  display: flex;
  gap: 9px;
  margin-left: auto;
}

.swatch {
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid transparent;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.07);
}

.swatch.is-active {
  border-color: var(--text);
  box-shadow: none;
}

.seg {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-top: 10px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--card);
}

.seg-btn {
  padding: 10px 2px;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
}

.seg-btn.is-active {
  background: var(--accent);
  color: #fff;
}

.export-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.export-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px 11px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  box-shadow: 0 6px 18px rgba(70, 60, 40, 0.05);
}

.export-label {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 14px;
  font-weight: 700;
}

.export-count {
  flex: 0 0 auto;
  font-size: 12px;
  color: var(--muted);
}

.history-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.history-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  box-shadow: 0 6px 18px rgba(70, 60, 40, 0.05);
}

.history-item.is-starred {
  border-color: rgba(224, 162, 60, 0.5);
}

.history-item.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(47, 107, 255, 0.16);
}

.history-item-main {
  flex: 1 1 auto;
  min-width: 0;
}

.item-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

/* 右侧竖向控制栏：上箭头 + 收藏星标，两者同列 */
.item-rail {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.item-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 7px;
}

.chev-slot {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
}

.item-foot .history-item-meta {
  flex: 1 1 auto;
  min-width: 0;
}

.batch-check {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin-top: 2px;
  border-radius: 6px;
  border: 1.5px solid var(--line);
  background: #fff;
}

.history-item.is-selected .batch-check {
  background: var(--accent);
  border-color: var(--accent);
}

.history-item-body {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 15px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  cursor: pointer;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}

.history-item-body.is-open {
  display: block;
  -webkit-line-clamp: unset;
  line-clamp: unset;
  overflow: visible;
}

.history-item-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.history-item-stamp {
  font-weight: 700;
  color: #6b6155;
  letter-spacing: 0.2px;
}

.history-item-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.dot-ok {
  background: #35a76a;
}

.dot-wait {
  background: #e0ab48;
}

.chev {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  margin-top: -1px;
  padding: 0;
  border-radius: 8px;
  background: transparent;
  color: #b3aca0;
}

.chev:active {
  background: rgba(0, 0, 0, 0.05);
}

.item-foot .chev {
  margin-top: 0;
}

.star {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 8px;
  background: transparent;
  color: #c9c2b6;
}

.star.is-on {
  color: #e0a23c;
}

.star:active {
  background: rgba(0, 0, 0, 0.05);
}

.hint {
  margin: 12px 2px 0;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translateX(-50%);
  max-width: min(88vw, 420px);
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(35, 32, 27, 0.9);
  color: #fff;
  font-size: 13px;
  text-align: center;
  z-index: 20;
}
