:root {
  --ink: #282820;
  --muted: #888276;
  --paper: #fffdf8;
  --canvas: #e8e3d9;
  --side: #f3efe6;
  --line: #dcd5c8;
  --accent: #df4d32;
  --accent-dark: #bd3822;
  --green: #537664;
  --shadow: 0 24px 70px rgba(47, 40, 28, 0.15);
}

* { box-sizing: border-box; }

.portfolio-back {
  position: fixed;
  top: 12px;
  right: 20px;
  z-index: 50;
  padding: 8px 13px;
  border: 1px solid rgba(35, 34, 28, 0.16);
  border-radius: 999px;
  color: #5f5a50;
  background: rgba(252, 250, 244, 0.9);
  box-shadow: 0 5px 20px rgba(48, 43, 35, 0.08);
  font: 500 12px "Noto Sans SC", sans-serif;
  text-decoration: none;
  backdrop-filter: blur(12px);
}

.portfolio-back:hover {
  color: #dd5338;
  border-color: rgba(221, 83, 56, 0.3);
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 10%, rgba(255,255,255,.65), transparent 28%),
    linear-gradient(135deg, #ded8cd, #eeeae2 55%, #ddd7cc);
  font-family: "Noto Sans SC", system-ui, sans-serif;
}

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

.app-shell {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  width: min(1420px, calc(100vw - 48px));
  height: min(900px, calc(100vh - 48px));
  min-height: 620px;
  margin: 24px auto;
  overflow: hidden;
  background: var(--paper);
  border: 1px solid rgba(117, 106, 88, .25);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 32px 24px 20px;
  background:
    linear-gradient(rgba(70, 63, 50, .025) 1px, transparent 1px),
    var(--side);
  background-size: 100% 28px;
  border-right: 1px solid var(--line);
  z-index: 20;
}

.brand-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 26px; }
.eyebrow { margin: 0 0 2px; color: var(--muted); font: 500 10px/1 "DM Mono", monospace; letter-spacing: .22em; }
.brand-row h1 { margin: 0; font: 700 31px/1.25 "Noto Serif SC", serif; letter-spacing: .06em; }
.brand-dot { color: var(--accent); }

.new-note-button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  color: white;
  background: var(--ink);
  border: 0;
  border-radius: 9px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 6px 14px rgba(40, 40, 32, .14);
  transition: transform .18s ease, background .18s ease;
}
.new-note-button:hover { transform: translateY(-1px); background: #3a3930; }
.new-note-button span { color: #f07c62; font-size: 20px; font-weight: 400; }
.new-note-button kbd { margin-left: auto; color: #bdbbad; border: 0; }

.storage-panel {
  margin-top: 14px;
  background: rgba(255, 253, 248, 0.62);
}

.storage-panel h3 {
  font-family: "Noto Serif SC", serif;
}

.storage-panel p {
  color: var(--muted);
}

kbd { font: 500 10px/1 "DM Mono", monospace; }
.search-box {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 18px 0 20px;
  padding: 0 11px;
  height: 42px;
  color: var(--muted);
  background: rgba(255,255,255,.58);
  border: 1px solid var(--line);
  border-radius: 8px;
  transition: background .2s, border .2s;
}
.search-box:focus-within { background: white; border-color: #aaa295; }
.search-box svg, .icon-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.search-box input { width: 100%; min-width: 0; color: var(--ink); background: transparent; border: 0; outline: 0; font-size: 13px; }
.search-box input::placeholder { color: #a39d91; }
.search-box kbd { white-space: nowrap; color: #aaa397; }

.list-heading { display: flex; justify-content: space-between; padding: 0 4px 10px; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .08em; }
.notes-list { flex: 1; min-height: 0; overflow-y: auto; padding-right: 4px; scrollbar-width: thin; scrollbar-color: #c8c0b4 transparent; }
.note-card {
  position: relative;
  margin-bottom: 7px;
  padding: 15px 15px 14px 17px;
  border: 1px solid transparent;
  border-radius: 9px;
  cursor: pointer;
  transition: background .18s, border .18s, transform .18s;
}
.note-card:hover { background: rgba(255,255,255,.55); transform: translateX(2px); }
.note-card.active { background: var(--paper); border-color: #d8d0c2; box-shadow: 0 5px 14px rgba(76, 65, 46, .06); }
.note-card.active::before { content: ""; position: absolute; left: -1px; top: 13px; bottom: 13px; width: 3px; background: var(--accent); border-radius: 0 3px 3px 0; }
.note-card-head { display: flex; align-items: center; gap: 7px; }
.note-card h3 { flex: 1; min-width: 0; margin: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font: 600 14px/1.4 "Noto Serif SC", serif; }
.pin-mark { flex: 0 0 auto; color: var(--accent); font-size: 11px; transform: rotate(-18deg); }
.note-card p { height: 34px; margin: 6px 0 10px; overflow: hidden; color: var(--muted); font-size: 12px; line-height: 1.45; }
.note-card-meta { display: flex; justify-content: space-between; color: #aaa397; font: 400 10px/1.2 "DM Mono", monospace; }
.no-results { padding: 50px 16px; color: var(--muted); text-align: center; font-size: 13px; line-height: 1.8; }

.sidebar-footer { display: flex; align-items: center; justify-content: space-between; padding: 18px 4px 0; color: var(--muted); border-top: 1px solid var(--line); font-size: 11px; }
.status-light { display: inline-block; width: 6px; height: 6px; margin-right: 7px; background: #70a383; border-radius: 50%; box-shadow: 0 0 0 3px rgba(112,163,131,.12); }
.text-button { color: var(--muted); background: none; border: 0; cursor: pointer; font-size: 11px; }
.text-button:hover { color: var(--accent); }

.editor-pane { position: relative; display: flex; flex-direction: column; min-width: 0; background: var(--paper); }
.editor-toolbar { display: flex; align-items: center; gap: 18px; height: 70px; padding: 0 28px; border-bottom: 1px solid #ece7de; }
.crumb { display: flex; align-items: center; min-width: 0; gap: 9px; color: #aaa397; font-size: 11px; }
.crumb strong { max-width: 260px; overflow: hidden; color: #696359; font-weight: 500; white-space: nowrap; text-overflow: ellipsis; }
.toolbar-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.save-state { margin-right: 10px; color: var(--green); font-size: 11px; transition: color .2s; }
.save-state.saving { color: var(--accent); }
.icon-button { display: grid; place-items: center; width: 36px; height: 36px; color: #777065; background: transparent; border: 0; border-radius: 7px; cursor: pointer; transition: color .18s, background .18s; }
.icon-button:hover { color: var(--ink); background: #f3efe8; }
.icon-button.danger:hover { color: var(--accent); background: #fff0eb; }
.icon-button.pinned { color: var(--accent); background: #fff0eb; }
.mobile-close, .menu-button { display: none; }

.paper { flex: 1; width: min(820px, calc(100% - 80px)); min-height: 0; margin: 0 auto; padding: 64px 10px 32px; }
.paper-meta { display: flex; align-items: center; gap: 13px; color: #aaa397; font: 400 10px/1 "DM Mono", monospace; text-transform: uppercase; letter-spacing: .05em; }
.meta-rule { width: 35px; height: 1px; background: #d6cfc3; }
.title-input { display: block; width: 100%; margin: 27px 0 22px; padding: 0; color: var(--ink); background: transparent; border: 0; outline: 0; font: 700 clamp(30px, 4vw, 48px)/1.25 "Noto Serif SC", serif; letter-spacing: .01em; }
.title-input::placeholder { color: #c9c2b6; }
.content-input { display: block; width: 100%; height: calc(100% - 135px); min-height: 250px; resize: none; padding: 0 0 100px; color: #4b4941; background: transparent; border: 0; outline: 0; font: 400 16px/2 "Noto Sans SC", sans-serif; letter-spacing: .025em; scrollbar-width: thin; scrollbar-color: #d6cfc3 transparent; }
.content-input::placeholder { color: #bcb5a9; }
.editor-footer { display: flex; align-items: center; justify-content: space-between; min-height: 48px; padding: 0 34px; color: #aaa397; border-top: 1px solid #ece7de; font-size: 10px; }
.writing-hint { font-family: "Noto Serif SC", serif; font-size: 11px; letter-spacing: .08em; }
.writing-hint span { margin-right: 7px; color: var(--accent); }
.separator { margin: 0 7px; }

.empty-state { position: absolute; inset: 70px 0 48px; z-index: 3; place-content: center; text-align: center; background: var(--paper); }
.empty-state:not([hidden]) { display: grid; }
.empty-mark { display: grid; place-items: center; width: 80px; height: 96px; margin: 0 auto 18px; color: #b3a99a; background: #f4f0e8; border: 1px solid #ddd6ca; border-radius: 4px 14px 4px 4px; font: 600 25px "Noto Serif SC", serif; transform: rotate(-2deg); }
.empty-state h2 { margin: 0; font: 700 25px "Noto Serif SC", serif; }
.empty-state p { margin: 8px 0 24px; color: var(--muted); font-size: 13px; }
.new-note-button.compact { width: auto; margin: auto; padding-inline: 22px; }
.sidebar-backdrop { display: none; }
.toast { position: fixed; left: 50%; bottom: 36px; z-index: 100; padding: 10px 16px; color: white; background: rgba(40,40,32,.92); border-radius: 7px; font-size: 12px; opacity: 0; pointer-events: none; transform: translate(-50%, 12px); transition: .24s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.local-data-intro {
  font-family: "Noto Sans SC", system-ui, sans-serif;
}

@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; width: 100vw; height: 100vh; min-height: 0; margin: 0; border: 0; border-radius: 0; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(340px, 88vw); transform: translateX(-105%); transition: transform .28s ease; box-shadow: 14px 0 40px rgba(43,37,28,.18); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop { position: fixed; inset: 0; z-index: 10; background: rgba(38,35,30,.32); backdrop-filter: blur(2px); }
  .sidebar-backdrop.show { display: block; }
  .mobile-close, .menu-button { display: grid; }
  .paper { width: calc(100% - 40px); padding-top: 40px; }
  .editor-toolbar { padding: 0 16px; }
  .crumb > span { display: none; }
  .save-state { display: none; }
  .editor-footer { padding: 0 20px; }
  .writing-hint { display: none; }
  .editor-footer > div:last-child { margin-left: auto; }
  .local-data-intro { padding-inline: 16px; }
}

@media (max-width: 480px) {
  .paper { width: calc(100% - 30px); padding-top: 30px; }
  .title-input { margin-top: 20px; font-size: 31px; }
  .content-input { font-size: 15px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
