:root {
  --ink: #1e2430;
  --accent: #9f3a2d;
  --accent-deep: #7e2d23;
  --accent-soft: rgba(159, 58, 45, 0.12);
  --paper: #f1e5d2;
  --paper-soft: #f8efe1;
  --paper-strong: #fff8ec;
  --card: rgba(255, 248, 236, 0.9);
  --card-strong: #fffaf0;
  --line: #d8c5ad;
  --line-strong: #c3ae90;
  --muted: #6d665d;
  --danger: #8f3428;
  --shadow: 0 24px 60px rgba(97, 70, 43, 0.12);
  --shadow-soft: 0 10px 30px rgba(97, 70, 43, 0.08);
  font-family: Georgia, "Times New Roman", serif;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  line-height: 1.6;
  background:
    radial-gradient(circle at top right, rgba(222, 160, 106, 0.36), transparent 22rem),
    radial-gradient(circle at top left, rgba(255, 248, 233, 0.9), transparent 18rem),
    linear-gradient(180deg, #fbf4e7 0%, var(--paper) 48%, #ece0cc 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.22), transparent 28%),
    radial-gradient(circle at 18% 12%, rgba(255, 255, 255, 0.18), transparent 24%);
  opacity: 0.65;
}

body.modal-open {
  overflow: hidden;
}

a {
  color: var(--accent);
  text-decoration: none;
  text-underline-offset: 0.18em;
}

a:hover {
  color: var(--accent-deep);
}

img {
  max-width: 100%;
  display: block;
}

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

h1,
h2,
h3,
h4,
h5,
h6 {
  margin: 0 0 0.45rem;
  color: var(--ink);
  line-height: 1.15;
  font-weight: 700;
}

p {
  margin: 0;
}

code,
pre {
  font-family: "Cascadia Code", "Consolas", monospace;
}

button,
.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--accent);
  color: #fffaf5;
  padding: 0.82rem 1.2rem;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(159, 58, 45, 0.18);
  transition: transform 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

button:hover,
.button-link:hover {
  transform: translateY(-1px);
  background: var(--accent-deep);
  box-shadow: 0 14px 28px rgba(126, 45, 35, 0.22);
  color: #fffaf5;
}

.action-link {
  padding: 0.72rem 1.05rem;
  font-size: 0.96rem;
}

.copy-button.soft-copy-button {
  background: rgba(255, 248, 236, 0.9);
  color: var(--accent-deep);
  border-color: rgba(159, 58, 45, 0.22);
  box-shadow: 0 8px 22px rgba(126, 45, 35, 0.1);
}

.copy-button.soft-copy-button:hover {
  background: rgba(255, 243, 225, 0.98);
  color: var(--accent-deep);
  box-shadow: 0 12px 26px rgba(126, 45, 35, 0.14);
}

button:focus-visible,
.button-link:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 2px solid rgba(159, 58, 45, 0.28);
  outline-offset: 2px;
}

.button-link {
  text-decoration: none;
}

.ghost-button {
  background: rgba(255, 251, 245, 0.8);
  color: var(--ink);
  border-color: rgba(195, 174, 144, 0.78);
  box-shadow: none;
}

.ghost-button:hover {
  background: rgba(255, 247, 235, 0.96);
  color: var(--ink);
}

.danger {
  background: var(--danger);
}

.danger:hover {
  background: #7b271d;
}

.page-shell {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100% - 1.6rem));
  margin: 0 auto;
  padding: 1.4rem 0 3.2rem;
  animation: page-enter 320ms ease;
}

.topbar,
.brand-wrap,
.nav,
.actions,
.toolbar,
.hero-card,
.card-title-row,
.link-list {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.topbar,
.hero-card,
.card-title-row {
  justify-content: space-between;
  align-items: flex-start;
}

.topbar {
  align-items: center;
  margin-bottom: 1.15rem;
  padding: 0.85rem 0 0.2rem;
}

.brand-wrap {
  align-items: baseline;
}

.brand {
  color: var(--ink);
  display: inline-flex;
  align-items: baseline;
  gap: 1.14rem;
  letter-spacing: 0.01em;
  line-height: 1;
}

.brand-rondel {
  font-family: "Italianno", "Times New Roman", cursive;
  font-size: 3.2rem;
  font-style: italic;
  font-weight: 400;
  line-height: 0.8;
  color: var(--accent-deep);
}

.brand-note {
  font-family: "Cinzel Decorative", Georgia, serif;
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
}

.nav {
  align-items: center;
}

.nav a,
.nav form {
  margin: 0;
}

.nav a {
  display: inline-flex;
  align-items: center;
  padding: 0.58rem 0.92rem;
  border-radius: 999px;
  color: var(--muted);
  border: 1px solid transparent;
}

.nav a:hover {
  background: rgba(255, 251, 245, 0.74);
  border-color: rgba(216, 197, 173, 0.86);
}

.nav a.active {
  background: var(--accent-soft);
  border-color: rgba(159, 58, 45, 0.18);
  color: var(--accent-deep);
}

.card {
  position: relative;
  background: var(--card);
  backdrop-filter: blur(10px);
  border-radius: 26px;
  border: 1px solid rgba(216, 197, 173, 0.92);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.7), transparent 72%);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.grid-two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.notes-toolbar-grid {
  align-items: stretch;
}

.list-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}

.list-grid.compact {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.note-app-grid {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
  align-items: start;
}

.notes-search-card {
  width: 100%;
  padding: 0.95rem 1rem;
}

.notes-search-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.9rem;
  align-items: center;
}

.notes-search-form input[type="search"] {
  min-width: 0;
  margin: 0;
}

.notes-search-form button {
  min-width: 6.8rem;
  padding-inline: 1.3rem;
  margin: 0;
}

.hero-card {
  background:
    linear-gradient(180deg, rgba(255, 251, 244, 0.96), rgba(249, 239, 224, 0.92));
}

.meta-line,
.muted {
  color: var(--muted);
}

.meta-line {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
  font-size: 0.96rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 0.28rem 0.72rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  border: 1px solid rgba(159, 58, 45, 0.12);
  font-size: 0.88rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.38rem;
}

label > span {
  color: #4c4842;
}

input[type="text"],
input[type="search"],
input[type="password"],
input[type="number"],
textarea,
select {
  width: 100%;
  border-radius: 18px;
  border: 1px solid rgba(195, 174, 144, 0.88);
  background: rgba(255, 253, 248, 0.96);
  color: var(--ink);
  padding: 0.84rem 0.96rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

input::placeholder,
textarea::placeholder {
  color: #8d8071;
}

select[multiple] {
  min-height: 12rem;
}

textarea {
  resize: vertical;
}

.toolbar {
  align-items: end;
}

.toolbar > * {
  flex: 1 1 220px;
}

.toolbar > button {
  flex: 0 0 auto;
}

.table-wrap,
.mono-content {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  border-bottom: 1px solid rgba(216, 197, 173, 0.85);
  padding: 0.88rem 0.7rem;
  vertical-align: top;
}

th {
  color: #564d43;
  font-weight: 700;
}

tbody tr:hover {
  background: rgba(255, 250, 241, 0.66);
}

.mono-card {
  background: linear-gradient(180deg, #2f2a29, #221d1d);
  color: #f4ebdf;
  border-color: rgba(126, 103, 85, 0.85);
  box-shadow: 0 20px 46px rgba(44, 32, 26, 0.24);
}

.mono-card::before {
  background: linear-gradient(90deg, rgba(255, 232, 206, 0.2), transparent 72%);
}

.mono-card .chip {
  background: rgba(255, 242, 225, 0.12);
  border-color: rgba(255, 242, 225, 0.08);
  color: #f2d7be;
}

.mono-card .copy-button {
  background: rgba(255, 248, 236, 0.1);
  border-color: rgba(255, 248, 236, 0.12);
  box-shadow: none;
}

.mono-card .copy-button:hover {
  background: rgba(255, 248, 236, 0.16);
}

.mono-card.inset {
  margin-top: 1rem;
}

.mono-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  margin-bottom: 0.75rem;
}

.content-meta {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.type-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.28rem 0.72rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 238, 214, 0.16);
  background: rgba(255, 248, 236, 0.08);
  color: #e9d3bb;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.mono-content {
  margin: 0;
  white-space: pre-wrap;
  max-height: 520px;
  padding: 1rem;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 236, 214, 0.08);
}

.auth-card {
  width: min(460px, 100%);
}

.centered-main {
  min-height: 72vh;
  display: grid;
  place-items: center;
}

.drop-card {
  border: 1px dashed rgba(159, 58, 45, 0.36);
  border-radius: 22px;
  padding: 1rem;
  background: linear-gradient(180deg, rgba(255, 252, 246, 0.95), rgba(247, 236, 219, 0.85));
}

.upload-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.tree-item {
  border-left: 2px solid rgba(159, 58, 45, 0.22);
  padding-left: 1rem;
  margin-bottom: 1rem;
}

.file-badge {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 1rem;
  border-radius: 20px;
  background: rgba(255, 252, 247, 0.7);
  border: 1px solid rgba(216, 197, 173, 0.92);
  box-shadow: var(--shadow-soft);
}

.note-card {
  padding: 1.1rem 1.15rem 1rem;
  box-shadow: var(--shadow-soft);
  cursor: grab;
  min-height: 13.2rem;
  display: flex;
  flex-direction: column;
}

.note-card.dragging {
  opacity: 0.55;
}

.note-card.drag-over,
.group-folder-card.drag-over {
  background: rgba(255, 245, 229, 0.98);
  outline: 1px dashed rgba(159, 58, 45, 0.28);
  outline-offset: -7px;
}

.note-card-top {
  margin-bottom: 0.7rem;
  align-items: flex-start;
}

.note-card-top h3 {
  font-size: 1.45rem;
  line-height: 1.08;
}

.note-card .excerpt {
  margin: 0 0 1.15rem;
  color: #50483f;
}

.note-card-footer {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 0.75rem;
}

.note-card-footer-left {
  display: flex;
  align-items: flex-end;
  min-height: 2.6rem;
}

.note-card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  flex-wrap: wrap;
  align-items: center;
}

.note-card-actions button,
.note-card-actions .button-link {
  padding: 0.58rem 0.9rem;
  font-size: 0.88rem;
}

.note-card-top .copy-button {
  padding: 0.52rem 0.88rem;
  font-size: 0.86rem;
  min-width: 4.6rem;
}

.note-secondary-button {
  padding: 0.42rem 0.78rem;
  font-size: 0.8rem;
  min-width: auto;
}

.subtle-danger {
  box-shadow: 0 8px 18px rgba(126, 45, 35, 0.12);
}

.group-folder-card {
  min-height: 14rem;
  padding: 1.1rem;
}

.group-folder-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.9rem;
  margin-bottom: 0.8rem;
}

.folder-open-link {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  color: var(--ink);
  flex: 1 1 auto;
}

.folder-open-link:hover {
  color: var(--ink);
}

.folder-glyph {
  width: 3rem;
  height: 3rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(159, 58, 45, 0.1), rgba(159, 58, 45, 0.04));
  color: var(--accent-deep);
  font-size: 1.55rem;
}

.folder-preview {
  display: grid;
  gap: 0.35rem;
  margin-top: 0.35rem;
}

.group-rename-button {
  flex: 0 0 auto;
  margin-top: 0.1rem;
}

.note-preview-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 1.2rem;
}

.note-preview-modal[hidden] {
  display: none;
}

.note-preview-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(30, 36, 48, 0.18);
  backdrop-filter: blur(6px);
}

.note-preview-dialog {
  position: relative;
  width: min(760px, 100%);
  max-height: min(82vh, 820px);
  overflow: auto;
  padding: 1.35rem;
}

.note-preview-content {
  margin: 1rem 0 0;
  white-space: pre-wrap;
  line-height: 1.8;
  color: #433d35;
  padding: 1rem 1.05rem;
  border-radius: 20px;
  border: 1px solid rgba(216, 197, 173, 0.88);
  background: linear-gradient(180deg, rgba(255, 252, 246, 0.95), rgba(247, 237, 223, 0.9));
}

.group-name-dialog {
  position: relative;
  width: min(560px, 100%);
  padding: 1.35rem;
}

.group-name-field {
  margin-top: 1rem;
}

.group-name-actions {
  justify-content: flex-end;
  margin-top: 0.4rem;
}

.note-preview-close-button {
  background: rgba(159, 58, 45, 0.12);
  color: var(--accent-deep);
  border: 1px solid rgba(159, 58, 45, 0.22);
  box-shadow: none;
}

.note-preview-close-button:hover {
  background: rgba(159, 58, 45, 0.18);
  color: var(--accent-deep);
  box-shadow: 0 8px 20px rgba(126, 45, 35, 0.12);
}

.folder-preview span {
  display: block;
  padding: 0.45rem 0.7rem;
  border-radius: 14px;
  background: rgba(255, 252, 247, 0.76);
  border: 1px solid rgba(216, 197, 173, 0.75);
  color: #5c5348;
}

.note-card-actions form {
  margin: 0;
}

.cover-preview {
  border-radius: 20px;
  border: 1px solid rgba(216, 197, 173, 0.92);
  box-shadow: var(--shadow-soft);
}

.small-text {
  font-size: 0.88rem;
  word-break: break-all;
}

.excerpt {
  color: #3b3b3b;
}

.markdown-body {
  margin-top: 1rem;
  display: grid;
  gap: 0.95rem;
}

.content-panel {
  padding: 1.15rem 1.2rem;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(255, 252, 246, 0.88), rgba(248, 239, 224, 0.82));
  border: 1px solid rgba(216, 197, 173, 0.9);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.58);
}

.markdown-body p,
.markdown-body ul,
.markdown-body ol,
.markdown-body blockquote,
.markdown-body pre {
  margin: 0;
}

.markdown-body pre,
.markdown-body code {
  font-size: 0.94rem;
}

.markdown-body pre {
  overflow: auto;
  padding: 0.95rem 1rem;
  border-radius: 18px;
  background: rgba(248, 240, 225, 0.82);
  border: 1px solid rgba(216, 197, 173, 0.9);
}

.markdown-body blockquote {
  padding-left: 1rem;
  border-left: 3px solid rgba(159, 58, 45, 0.25);
  color: #5e554b;
}

.link-list {
  margin-top: 0.9rem;
}

.link-list a {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.2rem 0;
  word-break: break-all;
}

.link-hint-list {
  display: grid;
  gap: 0.45rem;
}

.link-hint-list a {
  color: #f2d0b9;
  font-style: italic;
}

.link-hint-list a::before {
  content: "↗";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 999px;
  border: 1px solid rgba(242, 208, 185, 0.2);
  background: rgba(255, 248, 236, 0.08);
  color: #f2d0b9;
  font-style: normal;
  flex: 0 0 auto;
}

.markdown-body a {
  color: var(--accent-deep);
  font-style: italic;
  text-decoration: underline;
}

.markdown-body a::before {
  content: "↗";
  display: inline-block;
  margin-right: 0.35rem;
  color: var(--accent);
  font-style: normal;
}

.inline-form,
.inline-block {
  display: inline-block;
}

.compact-form {
  margin-top: 0.75rem;
}

.icon-button {
  min-width: 5rem;
}

.empty-card {
  min-height: 7rem;
  justify-content: center;
}

.toast {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 20;
  padding: 0.92rem 1rem;
  border-radius: 18px;
  box-shadow: 0 18px 40px rgba(84, 57, 35, 0.16);
  color: #fffaf5;
}

.toast.success {
  background: var(--accent);
}

.toast.error {
  background: #7d2e24;
}

@keyframes page-enter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 860px) {
  .grid-two,
  .upload-grid {
    grid-template-columns: 1fr;
  }

  .topbar,
  .hero-card,
  .card-title-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .toolbar > * {
    flex-basis: 100%;
  }

  .notes-search-card {
    width: 100%;
  }

  .notes-search-form {
    grid-template-columns: 1fr;
  }

  .page-shell {
    width: min(100% - 1rem, 1180px);
    padding-top: 1rem;
  }
}
