:root {
  color-scheme: dark;
  --ink: #17251d;
  --deep: #101a14;
  --moss: #6f8f68;
  --moss-bright: #a9c49f;
  --paper: #f0ebdd;
  --cream: #dcd4c3;
  --line: rgba(239, 235, 220, 0.14);
  --muted: #9ba79d;
  --danger: #bd6d62;
  --shadow: 0 26px 80px rgba(0, 0, 0, 0.28);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--deep); color: var(--paper); overflow-x: hidden; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.moss-glow { position: fixed; border-radius: 999px; filter: blur(90px); opacity: .18; pointer-events: none; }
.moss-glow-one { width: 460px; height: 460px; background: #93af83; left: -180px; top: -170px; }
.moss-glow-two { width: 380px; height: 380px; background: #496754; right: -120px; bottom: -180px; }
.eyebrow { margin: 0 0 8px; color: var(--moss-bright); font-size: 11px; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; }
.eyebrow.pale { color: rgba(255,255,255,.64); }

.login-view { min-height: 100vh; display: grid; place-items: center; padding: 24px; position: relative; z-index: 1; }
.login-card { width: min(460px, 100%); padding: 44px; border: 1px solid var(--line); border-radius: 28px; background: rgba(24, 38, 29, .86); backdrop-filter: blur(20px); box-shadow: var(--shadow); }
.login-card h1 { margin: 0; font-family: Georgia, "Songti SC", serif; font-size: clamp(34px, 8vw, 52px); font-weight: 500; letter-spacing: -.035em; }
.login-copy { color: var(--muted); line-height: 1.8; margin: 18px 0 28px; }
.house-mark { width: 58px; height: 58px; border: 1px solid rgba(169,196,159,.55); border-radius: 50%; display: grid; place-items: center; margin-bottom: 28px; position: relative; }
.house-mark::before, .house-mark::after, .house-mark span { content: ""; display: block; position: absolute; background: var(--moss-bright); border-radius: 60% 0 60% 0; transform: rotate(-38deg); }
.house-mark::before { width: 18px; height: 8px; left: 13px; top: 19px; }
.house-mark::after { width: 16px; height: 7px; right: 11px; bottom: 17px; transform: rotate(142deg); }
.house-mark span { width: 2px; height: 25px; border-radius: 3px; transform: rotate(23deg); }
.house-mark.small { width: 38px; height: 38px; margin: 0; flex: 0 0 auto; }
.house-mark.small::before { width: 12px; height: 6px; left: 8px; top: 12px; }
.house-mark.small::after { width: 11px; height: 5px; right: 7px; bottom: 11px; }
.house-mark.small span { height: 17px; }
.login-form label, .field { display: grid; gap: 8px; color: var(--cream); font-size: 13px; font-weight: 700; }
.secret-row { display: flex; border: 1px solid var(--line); background: rgba(255,255,255,.035); border-radius: 14px; overflow: hidden; }
.secret-row input { flex: 1; border: 0; background: transparent; color: var(--paper); padding: 14px 16px; outline: none; min-width: 0; }
.icon-button { width: 48px; border: 0; border-left: 1px solid var(--line); background: transparent; color: var(--muted); }
.form-error { color: #e09a8f; min-height: 20px; margin: 8px 0; font-size: 13px; }
.privacy-note { color: #718078; font-size: 11px; text-align: center; margin: 18px 0 0; }

.primary-button, .secondary-button { border: 0; border-radius: 12px; padding: 12px 18px; font-weight: 800; transition: transform .18s ease, background .18s ease; }
.primary-button { background: var(--paper); color: var(--ink); }
.primary-button:hover { transform: translateY(-1px); background: #fffdf5; }
.primary-button.wide { width: 100%; }
.secondary-button { background: rgba(255,255,255,.06); color: var(--paper); border: 1px solid var(--line); }
.text-button { border: 0; padding: 8px 4px; background: transparent; color: var(--cream); text-align: left; }
.text-button.muted { color: var(--muted); }

.app { min-height: 100vh; display: grid; grid-template-columns: 252px minmax(0, 1fr); position: relative; z-index: 1; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: 252px; padding: 28px 20px; border-right: 1px solid var(--line); background: rgba(15, 26, 19, .92); backdrop-filter: blur(18px); display: flex; flex-direction: column; z-index: 20; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 30px; }
.brand strong { font-family: Georgia, serif; font-weight: 500; display: block; font-size: 18px; }
.brand small { color: var(--muted); font-size: 9px; letter-spacing: .16em; }
.nav { display: grid; gap: 5px; }
.nav-item { display: grid; grid-template-columns: 30px 1fr; grid-template-rows: auto auto; gap: 0 5px; width: 100%; padding: 12px 14px; color: var(--muted); border: 1px solid transparent; border-radius: 13px; background: transparent; text-align: left; }
.nav-item span { grid-row: 1 / 3; font-size: 20px; align-self: center; color: #7e9482; }
.nav-item b { color: inherit; font-size: 14px; }
.nav-item small { font-size: 10px; opacity: .65; }
.nav-item:hover { background: rgba(255,255,255,.035); color: var(--cream); }
.nav-item.active { background: rgba(143,174,132,.12); color: var(--paper); border-color: rgba(169,196,159,.16); }
.nav-item.future { opacity: .58; }
.sidebar-footer { margin-top: auto; display: grid; padding: 20px 10px 0; border-top: 1px solid var(--line); }
.main { grid-column: 2; min-width: 0; padding: 36px clamp(22px, 4vw, 64px) 80px; }
.topbar { display: flex; align-items: center; gap: 24px; justify-content: space-between; margin-bottom: 34px; }
.topbar h2 { margin: 0; font-family: Georgia, "Songti SC", serif; font-size: clamp(22px, 3vw, 34px); font-weight: 400; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }
.search-box { height: 44px; display: flex; align-items: center; gap: 8px; padding: 0 13px; min-width: min(280px, 25vw); border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.035); }
.search-box span { color: var(--muted); font-size: 22px; }
.search-box input { width: 100%; color: var(--paper); background: transparent; border: 0; outline: none; }
.menu-button { display: none; border: 0; background: transparent; color: var(--paper); font-size: 24px; }

.dashboard { display: grid; grid-template-columns: 1.25fr 1fr; gap: 18px; }
.welcome-card { min-height: 190px; padding: 28px; border-radius: 22px; background: linear-gradient(135deg, #66825f, #3e5947); display: flex; justify-content: space-between; gap: 20px; box-shadow: 0 18px 50px rgba(0,0,0,.18); }
.welcome-card h3 { font-family: Georgia, "Songti SC", serif; margin: 0; font-size: 30px; font-weight: 400; }
.welcome-card p:not(.eyebrow) { max-width: 520px; color: rgba(255,255,255,.74); line-height: 1.75; }
.signal { align-self: flex-start; display: flex; align-items: center; gap: 8px; padding: 8px 11px; border-radius: 99px; background: rgba(10,20,13,.22); font-size: 10px; letter-spacing: .12em; }
.signal i { width: 7px; height: 7px; border-radius: 50%; background: #c8efb5; box-shadow: 0 0 14px #b9e8a4; }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.stat-grid article { min-height: 88px; padding: 18px; border: 1px solid var(--line); border-radius: 18px; background: rgba(255,255,255,.028); display: grid; grid-template-columns: 1fr auto; align-items: center; }
.stat-grid span { color: var(--muted); font-size: 12px; }
.stat-grid strong { grid-row: 1 / 3; grid-column: 2; font-family: Georgia, serif; font-size: 34px; font-weight: 400; }
.stat-grid small { color: #6e7c73; font-size: 10px; letter-spacing: .12em; }

.archive-section { margin-top: 42px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.section-heading h3 { margin: 0; font-family: Georgia, "Songti SC", serif; font-size: 25px; font-weight: 400; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
select, .field input, .field textarea { color: var(--paper); background: #18251d; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; outline: none; }
.filters select { color: var(--muted); font-size: 12px; }
.memory-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; }
.memory-card { min-width: 0; min-height: 210px; padding: 20px; border: 1px solid var(--line); border-radius: 18px; background: rgba(255,255,255,.026); display: flex; flex-direction: column; transition: transform .18s ease, border-color .18s ease, background .18s ease; }
.memory-card:hover { transform: translateY(-2px); border-color: rgba(169,196,159,.28); background: rgba(255,255,255,.04); }
.card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 16px; }
.badges { display: flex; flex-wrap: wrap; gap: 5px; }
.badge { padding: 4px 7px; border-radius: 99px; background: rgba(126,152,119,.13); color: var(--moss-bright); font-size: 9px; letter-spacing: .06em; text-transform: uppercase; }
.badge.draft { color: #dec28e; background: rgba(184,138,72,.13); }
.badge.intimate { color: #dda7a4; background: rgba(185,100,95,.12); }
.memory-card time { color: #6f7d73; font-size: 10px; }
.memory-card h4 { margin: 0 0 10px; font-family: Georgia, "Songti SC", serif; font-size: 19px; line-height: 1.4; font-weight: 400; }
.memory-card .excerpt { color: var(--muted); font-size: 12px; line-height: 1.7; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.tag-row { margin-top: auto; padding-top: 16px; display: flex; gap: 6px; flex-wrap: wrap; }
.tag-row span { color: #75847a; font-size: 10px; }
.card-actions { display: flex; gap: 7px; margin-top: 16px; }
.mini-button { border: 1px solid var(--line); background: transparent; color: var(--cream); border-radius: 9px; padding: 7px 9px; font-size: 11px; }
.mini-button.confirm { border-color: rgba(169,196,159,.35); background: rgba(130,161,119,.12); color: var(--moss-bright); }
.mini-button.danger { border-color: rgba(191,118,105,.35); color: #d9aaa2; }
.empty-state { padding: 80px 20px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 18px; }
.empty-state span { font-size: 42px; color: var(--moss); }
.empty-state h4 { color: var(--cream); margin: 12px 0 4px; }

.composer { margin: 4px 0 34px; }
.composer-card { display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, .45fr); gap: 28px; padding: 28px; border: 1px solid var(--line); border-radius: 22px; background: rgba(255,255,255,.025); }
.composer-card h3 { font-family: Georgia, "Songti SC", serif; font-size: 26px; font-weight: 400; margin: 0 0 8px; }
.composer-card p { color: var(--muted); line-height: 1.7; }
.composer-card .primary-button { align-self: end; justify-self: end; }
.room-placeholder { min-height: 280px; display: grid; place-items: center; text-align: center; padding: 40px; border: 1px dashed var(--line); border-radius: 22px; color: var(--muted); }
.room-placeholder span { font-size: 44px; color: var(--moss); }
.room-placeholder h3 { color: var(--cream); font-family: Georgia, "Songti SC", serif; font-weight: 400; }

.editor-dialog { width: min(760px, calc(100% - 28px)); max-height: calc(100vh - 28px); padding: 0; color: var(--paper); border: 1px solid var(--line); border-radius: 24px; background: #142019; box-shadow: var(--shadow); }
.editor-dialog::backdrop { background: rgba(3, 8, 5, .72); backdrop-filter: blur(6px); }
.editor-dialog form { padding: 28px; overflow: auto; }
.dialog-header { display: flex; justify-content: space-between; align-items: start; margin-bottom: 24px; }
.dialog-header h3 { font-family: Georgia, "Songti SC", serif; font-size: 27px; font-weight: 400; margin: 0; }
.close-button { border: 0; background: transparent; color: var(--muted); font-size: 30px; }
.field-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.wide-field { grid-column: 1 / -1; }
.field textarea { resize: vertical; line-height: 1.65; }
.field output { color: var(--moss-bright); float: right; }
.field input[type="range"] { padding: 0; accent-color: var(--moss-bright); }
.draft-notice { color: #829188; font-size: 12px; margin: 20px 0 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 24px; }
.toast { position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 16px); padding: 11px 16px; border: 1px solid var(--line); border-radius: 12px; color: var(--paper); background: #26382b; opacity: 0; pointer-events: none; transition: .2s ease; z-index: 100; box-shadow: var(--shadow); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1080px) {
  .dashboard { grid-template-columns: 1fr; }
  .memory-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar { align-items: flex-start; }
  .topbar-actions { flex-wrap: wrap; justify-content: flex-end; }
}

@media (max-width: 760px) {
  .app { display: block; }
  .sidebar { transform: translateX(-102%); transition: transform .2s ease; width: min(300px, 86vw); }
  .sidebar.open { transform: translateX(0); }
  .main { padding: 22px 16px 70px; }
  .menu-button { display: block; }
  .topbar { display: grid; grid-template-columns: auto 1fr; gap: 12px; margin-bottom: 24px; }
  .topbar-actions { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr auto; width: 100%; }
  .search-box { min-width: 0; }
  .dashboard { display: block; }
  .welcome-card { min-height: 220px; }
  .stat-grid { margin-top: 12px; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .filters { justify-content: flex-start; width: 100%; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; }
  .filters select { flex: 0 0 auto; }
  .memory-list { grid-template-columns: 1fr; }
  .memory-card { min-height: 190px; }
  .composer-card { grid-template-columns: 1fr; }
  .composer-card .primary-button { justify-self: stretch; }
  .field-grid { grid-template-columns: 1fr; }
  .wide-field { grid-column: auto; }
  .login-card { padding: 32px 24px; }
}
