/* 与 EasyNote 主站主色、卡片风格接近（浅色系） */
:root {
  --primary: #3c77fb;
  --primary-light: #e0eeff;
  --primary-foreground: #fff;
  --background: #f4f6f9;
  --foreground: #1a1a1a;
  --card: #ffffff;
  --border: #e8eaed;
  --muted-foreground: #6b7280;
  --ring: #096dd9;
  --radius: 0.5rem;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.08);
  font-family:
    "Segoe UI",
    system-ui,
    -apple-system,
    "PingFang SC",
    "Microsoft YaHei",
    sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--background);
  color: var(--foreground);
}

code {
  font-size: 0.85em;
  background: #f0f2f5;
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: min(2000px, 100%);
  margin: 0 auto;
  padding: 0 clamp(0.5rem, 1.2vw, 1.5rem) 1.5rem;
  box-sizing: border-box;
}

.app-header {
  padding: 1rem 0 0.75rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.app-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.45rem;
  flex-shrink: 0;
  background: linear-gradient(150deg, #050d18 0%, #0c1f3d 55%, #0a1630 100%);
  border: 1px solid rgba(80, 220, 255, 0.45);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.35) inset,
    0 0 18px rgba(60, 119, 251, 0.28);
}

.app-logo-mark {
  width: 1.85rem;
  height: 1.85rem;
  display: block;
}

.app-logo-term {
  fill: #040c18;
  stroke: rgba(90, 210, 255, 0.75);
  stroke-width: 0.9;
}

.app-logo-prompt {
  fill: none;
  stroke: #7aeeff;
  stroke-width: 1.2;
  opacity: 0.9;
}

.app-logo-play {
  fill: url(#app-logo-play-grad);
}

.app-logo-cursor {
  fill: #3c77fb;
  opacity: 0.95;
}

.app-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.app-subtitle {
  margin: 0.15rem 0 0;
  font-size: 0.8rem;
  color: var(--muted-foreground);
}

.load-err {
  margin: 0 0 0.75rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  color: #b91c1c;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
}

.field-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted-foreground);
  margin-bottom: 0.25rem;
}

.input {
  width: 100%;
  padding: 0.5rem 0.65rem;
  font-size: 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--foreground);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}
.select {
  cursor: pointer;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.btn-primary {
  background: var(--primary);
  color: var(--primary-foreground);
}
.btn-primary:hover {
  filter: brightness(1.05);
}
.btn-ghost {
  background: transparent;
  color: var(--primary);
  padding: 0.35rem 0.5rem;
}
.btn-ghost:hover {
  background: var(--primary-light);
}

.field-error {
  color: #dc2626;
  font-size: 0.8rem;
  margin: 0.5rem 0 0;
}

/* 主区：左侧宽度由 --sidebar-px 控制，中间 6px 为可拖分栏 */
.main-grid {
  --sidebar-px: 352px;
  display: grid;
  grid-template-columns: var(--sidebar-px) 6px minmax(0, 1fr);
  gap: 0;
  flex: 1;
  min-height: 0;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.main-grid-resize {
  position: relative;
  z-index: 2;
  width: 6px;
  margin: 0;
  padding: 0;
  border: none;
  cursor: col-resize;
  touch-action: none;
  background: linear-gradient(
    to right,
    transparent 0 2px,
    var(--border) 2px 4px,
    transparent 4px 100%
  );
  flex-shrink: 0;
  transition: background 0.12s;
}
.main-grid-resize:hover,
.main-grid-resize:focus-visible {
  background: var(--primary-light);
  box-shadow: inset 0 0 0 1px rgba(60, 119, 251, 0.35);
  outline: none;
}
.main-grid-resize:active {
  background: #cfe4ff;
}

.panel {
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.panel-list {
  background: #fafbfc;
}
.panel-reader {
  background: #fff;
}

.panel-toolbar {
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.toolbar-row {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.toolbar-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.25rem;
  border-top: 1px dashed var(--border);
  margin-top: 0.2rem;
}
.list-meta {
  font-size: 0.8rem;
  color: var(--muted-foreground);
}

.list-scroll {
  flex: 1;
  overflow: auto;
  min-height: 200px;
  max-height: calc(100vh - 12rem);
}

.note-list {
  list-style: none;
  margin: 0;
  padding: 0.5rem 0.6rem 1rem;
}
.note-list li {
  margin: 0 0 0.5rem;
}
.note-card {
  width: 100%;
  text-align: left;
  display: block;
  padding: 0.75rem 0.85rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #fff;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.note-card:hover {
  border-color: #c7d2fe;
  background: #fafcff;
}
.note-card[aria-selected="true"] {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 0 0 1px rgba(60, 119, 251, 0.25);
}
.note-card-title {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--foreground);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.note-card-creator {
  margin: 0.35rem 0 0;
  font-size: 0.7rem;
  color: var(--muted-foreground);
  line-height: 1.3;
  word-break: break-all;
}
.note-card-time {
  margin: 0.2rem 0 0;
  font-size: 0.65rem;
  color: var(--muted-foreground);
}

.list-empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--muted-foreground);
  font-size: 0.85rem;
}

.panel-reader {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.reader-head {
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid var(--border);
  background: #fafbfc;
}
.reader-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.4;
  word-break: break-word;
}
.reader-meta {
  margin: 0.35rem 0 0;
  font-size: 0.7rem;
  color: var(--muted-foreground);
  word-break: break-all;
}

.markdown-body {
  padding: 1rem 1.1rem 2rem;
  overflow: auto;
  flex: 1;
  min-height: 0;
  max-height: calc(100vh - 11rem);
  line-height: 1.65;
  font-size: 0.9rem;
}
.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
  margin-top: 1.25em;
  margin-bottom: 0.5em;
  font-weight: 600;
}
.markdown-body p {
  margin: 0.6em 0;
}
.markdown-body pre {
  background: #f0f2f5;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  overflow: auto;
  font-size: 0.82rem;
}
.markdown-body code {
  background: #f0f2f5;
  padding: 0.1em 0.35em;
  border-radius: 4px;
  font-size: 0.88em;
}
.markdown-body a {
  color: var(--primary);
}

.prose {
  color: var(--foreground);
}

@media (max-width: 900px) {
  .main-grid {
    grid-template-columns: 1fr;
  }
  .main-grid-resize {
    display: none;
  }
  .panel-list {
    border-bottom: 1px solid var(--border);
    max-height: 55vh;
  }
  .list-scroll {
    max-height: 40vh;
  }
  .markdown-body {
    max-height: none;
  }
}
