:root {
  --bg-0: #0c1f18;
  --bg-1: #123028;
  --bg-2: #1a3f34;
  --surface: rgba(232, 245, 238, 0.96);
  --surface-2: #f3faf6;
  --ink: #102820;
  --ink-soft: #4a6b5c;
  --line: rgba(16, 40, 32, 0.12);
  --accent: #1f8a5f;
  --accent-deep: #146847;
  --danger: #b42318;
  --danger-soft: #fef3f2;
  --radius: 16px;
  --shadow: 0 18px 40px rgba(6, 24, 16, 0.28);
  --font: "IBM Plex Sans", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: "JetBrains Mono", "Consolas", monospace;
  --drawer-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(120% 80% at 10% -10%, #2a7a58 0%, transparent 55%),
    radial-gradient(90% 70% at 100% 0%, #c4a035 0%, transparent 45%),
    linear-gradient(165deg, var(--bg-0), var(--bg-1) 45%, var(--bg-2));
  background-attachment: fixed;
}

body {
  padding: 0 0 calc(88px + env(safe-area-inset-bottom));
}

body.drawer-open {
  overflow: hidden;
}

.app {
  width: min(720px, 100%);
  margin: 0 auto;
}

.hero {
  padding: calc(28px + env(safe-area-inset-top)) 20px 22px;
  color: #f4fff8;
  animation: rise 0.55s ease both;
}

.brand {
  margin: 0;
  font-size: clamp(2rem, 7vw, 2.75rem);
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.05;
}

.total-block {
  margin-top: 20px;
}

.total-label {
  display: inline-block;
  font-size: 0.85rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  opacity: 0.72;
}

.total-value {
  margin: 6px 0 0;
  font-family: var(--mono);
  font-size: clamp(2.1rem, 8vw, 3rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff6d6;
  text-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  animation: pulse-soft 2.8s ease-in-out infinite;
}

.meta {
  margin: 10px 0 0;
  font-size: 0.92rem;
  opacity: 0.78;
}

.main {
  display: grid;
  gap: 14px;
  padding: 0 14px;
}

.bottom-bar {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 30;
  width: min(720px, 100%);
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: rgba(10, 28, 22, 0.88);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(16px);
  box-shadow: 0 -12px 36px rgba(0, 0, 0, 0.28);
}

body.drawer-open .bottom-bar {
  opacity: 0;
  pointer-events: none;
}

.dock-btn {
  appearance: none;
  border: 0;
  border-radius: 14px;
  padding: 12px 10px;
  text-align: center;
  cursor: pointer;
  color: #f4fff8;
  background: rgba(255, 255, 255, 0.08);
  transition: transform 0.15s ease, background 0.2s;
}

.dock-btn:active {
  transform: scale(0.97);
  background: rgba(255, 255, 255, 0.14);
}

.dock-btn:focus-visible {
  outline: 2px solid #ffe9a8;
  outline-offset: 2px;
}

.dock-label {
  display: block;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.dock-sub {
  display: block;
  margin-top: 2px;
  font-size: 0.72rem;
  opacity: 0.62;
}

.panel {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  animation: rise 0.55s ease both;
  animation-delay: 0.1s;
}

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

.panel-head h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

textarea,
input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: var(--surface-2);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

textarea {
  resize: vertical;
  min-height: 140px;
  line-height: 1.55;
  font-family: var(--mono);
  font-size: 0.92rem;
}

textarea:focus,
input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 138, 95, 0.18);
}

.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin-bottom: 10px;
  border-radius: 14px;
  background: rgba(16, 40, 32, 0.06);
}

.seg-btn {
  border: 0;
  border-radius: 11px;
  padding: 10px 12px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  color: var(--ink-soft);
  background: transparent;
  transition: background 0.2s, color 0.2s, transform 0.15s;
}

.seg-btn.is-active {
  background: #fff;
  color: var(--accent-deep);
  box-shadow: 0 4px 14px rgba(16, 40, 32, 0.08);
}

.seg-btn:active {
  transform: scale(0.98);
}

.seg-hint {
  margin: 0 0 10px;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.row-actions,
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

.quick-form {
  display: grid;
  grid-template-columns: 1fr 88px;
  gap: 8px;
}

.btn {
  border: 0;
  border-radius: 12px;
  padding: 11px 16px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s, opacity 0.2s;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(180deg, var(--accent), var(--accent-deep));
  color: #fff;
}

.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
}

.btn-danger-ghost {
  background: transparent;
  color: var(--danger);
  padding: 4px 8px;
  font-size: 0.85rem;
}

.btn-icon {
  background: #e8f3ed;
  color: var(--ink);
  padding: 8px 10px;
  font-size: 0.82rem;
}

.btn-icon.danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.entry-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.entry-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  padding: 12px;
  border-radius: 14px;
  background: linear-gradient(135deg, #f7fcf9, #eef7f2);
  border: 1px solid var(--line);
  animation: rise 0.35s ease both;
}

.entry-main {
  min-width: 0;
}

.entry-content {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.92rem;
  word-break: break-all;
  line-height: 1.45;
  white-space: pre-wrap;
}

.entry-content.is-merge {
  max-height: 7.2em;
  overflow: auto;
  font-size: 0.84rem;
}

.entry-sub {
  margin: 6px 0 0;
  font-size: 0.84rem;
  color: var(--ink-soft);
}

.entry-sub strong {
  color: var(--accent-deep);
  font-family: var(--mono);
}

.entry-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  justify-content: center;
}

.empty {
  margin: 8px 0 0;
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.entry-list:not(:empty) + .empty {
  display: none;
}

.drawer-root {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.drawer-root[hidden] {
  display: none;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 18, 14, 0.52);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.28s ease;
}

.drawer-sheet {
  position: relative;
  width: min(720px, 100%);
  max-height: min(88vh, 640px);
  display: flex;
  flex-direction: column;
  border-radius: 22px 22px 0 0;
  background: var(--surface);
  box-shadow: 0 -16px 48px rgba(0, 0, 0, 0.28);
  padding: 0;
  transform: translateY(110%);
  transition: transform 0.34s var(--drawer-ease);
  will-change: transform;
  overflow: hidden;
}

.drawer-root.is-open .drawer-backdrop {
  opacity: 1;
}

.drawer-root.is-open .drawer-sheet {
  transform: translateY(0);
}

.drawer-sheet.is-dragging,
.drawer-root.is-dragging .drawer-backdrop {
  transition: none;
}

.drawer-grab {
  cursor: grab;
  user-select: none;
  touch-action: none;
  padding: 0 16px 2px;
  flex-shrink: 0;
}

.drawer-grab:active {
  cursor: grabbing;
}

.drawer-handle {
  width: 42px;
  height: 4px;
  border-radius: 999px;
  background: rgba(16, 40, 32, 0.22);
  margin: 10px auto 6px;
}

.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0 12px;
}

.drawer-head h2 {
  margin: 0;
  font-size: 1.2rem;
}

.drawer-desc {
  margin: 4px 0 0;
  font-size: 0.82rem;
  color: var(--ink-soft);
  line-height: 1.4;
}

.drawer-body {
  overflow: auto;
  padding: 0 16px 12px;
  touch-action: pan-y;
  overscroll-behavior: contain;
  flex: 1;
  min-height: 0;
}

.drawer-footer {
  flex-shrink: 0;
  display: flex;
  gap: 10px;
  justify-content: stretch;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(243, 250, 246, 0.96);
}

.drawer-footer .btn-ghost {
  flex: 0 0 auto;
}

.drawer-footer .drawer-cta {
  flex: 1;
  padding: 14px 16px;
  font-size: 1.02rem;
}

.drawer-footer [hidden] {
  display: none !important;
}

.drawer-panel[hidden] {
  display: none;
}

dialog {
  border: 0;
  border-radius: 18px;
  padding: 0;
  width: min(92vw, 420px);
  box-shadow: var(--shadow);
  background: var(--surface);
}

dialog::backdrop {
  background: rgba(8, 22, 16, 0.55);
  backdrop-filter: blur(3px);
}

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

.dialog-form h3 {
  margin: 0 0 4px;
}

.dialog-form label {
  display: grid;
  gap: 6px;
  font-size: 0.88rem;
  color: var(--ink-soft);
}

.dialog-preview {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.9rem;
  color: var(--accent-deep);
}

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

@keyframes pulse-soft {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.08); }
}
