:root {
  --bg: #f4f1eb;
  --panel: #fffdf9;
  --panel-border: #d8d1c6;
  --ink: #1f1c19;
  --muted: #6b645d;
  --accent: #1f5f52;
  --accent-strong: #15453b;
  --danger: #9e2f2f;
  --danger-strong: #7b2323;
  --line: #e3ddd3;
  --shadow: 0 18px 40px rgba(31, 28, 25, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(31, 95, 82, 0.08), transparent 32%),
    linear-gradient(180deg, #f7f5f0 0%, var(--bg) 100%);
}

a {
  color: inherit;
}

.shell {
  width: min(1120px, calc(100vw - 2rem));
  margin: 0 auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(10px);
  background: rgba(247, 245, 240, 0.92);
  border-bottom: 1px solid rgba(216, 209, 198, 0.85);
}

.topbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 4.5rem;
}

.brand {
  font-family: Georgia, serif;
  font-size: 1.2rem;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: 0.02em;
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.topbar__user {
  color: var(--muted);
  font-size: 0.95rem;
}

.content {
  padding: 2rem 0 4rem;
}

.page-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1.25rem;
}

.page-head__actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

h1 {
  margin: 0 0 0.35rem;
  font-family: Georgia, serif;
  font-size: clamp(1.9rem, 4vw, 2.8rem);
  line-height: 1.05;
}

p {
  line-height: 1.6;
}

.muted {
  margin: 0;
  color: var(--muted);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

.filters {
  display: grid;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.filters__main {
  display: grid;
  grid-template-columns: minmax(220px, 2.4fr) repeat(3, minmax(150px, 1fr));
  gap: 0.9rem;
}

.filters__actions,
.form-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.form-stack {
  display: grid;
  gap: 1rem;
}

.memo-form,
.delete-form,
.auth-card {
  width: min(860px, 100%);
}

.auth-card {
  margin: 3.5rem auto 0;
  padding: 2rem;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 22px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 1.5rem;
}

.field {
  display: grid;
  gap: 0.45rem;
}

.field span {
  font-weight: 600;
  font-size: 0.95rem;
}

.field--grow {
  min-width: 0;
}

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

input,
select,
textarea {
  width: 100%;
  padding: 0.85rem 0.95rem;
  border: 1px solid #cfc6b9;
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(31, 95, 82, 0.18);
  border-color: var(--accent);
}

.grid {
  display: grid;
  gap: 1rem;
}

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

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 2.8rem;
  padding: 0.7rem 1rem;
  border-radius: 999px;
  border: 1px solid transparent;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.14s ease, background-color 0.14s ease, border-color 0.14s ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button--primary {
  background: var(--accent);
  color: #fff;
}

.button--primary:hover {
  background: var(--accent-strong);
}

.button--ghost {
  background: rgba(31, 95, 82, 0.05);
  border-color: rgba(31, 95, 82, 0.18);
  color: var(--ink);
}

.button--danger {
  background: var(--danger);
  color: #fff;
}

.button--danger:hover {
  background: var(--danger-strong);
}

.is-disabled {
  opacity: 0.45;
  pointer-events: auto;
}

.table-wrap {
  overflow-x: auto;
}

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

.memo-table th,
.memo-table td {
  text-align: left;
  padding: 0.95rem 0.85rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.memo-table th {
  color: var(--muted);
  font-size: 0.88rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.memo-table a {
  text-decoration: none;
}

.memo-table a:hover {
  text-decoration: underline;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 700;
}

.badge--private {
  background: rgba(31, 95, 82, 0.12);
  color: var(--accent-strong);
}

.badge--business {
  background: rgba(34, 68, 123, 0.11);
  color: #24447b;
}

.badge--muted {
  background: rgba(107, 100, 93, 0.12);
  color: var(--muted);
}

.meta-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
  color: var(--muted);
}

.memo-content {
  margin-bottom: 1rem;
}

.memo-content p,
.memo-content ul {
  margin-top: 0;
}

.meta-panel {
  width: min(720px, 100%);
}

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

.meta-grid dt {
  color: var(--muted);
  font-size: 0.88rem;
  margin-bottom: 0.3rem;
}

.meta-grid dd {
  margin: 0;
}

.flash-stack {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.flash {
  padding: 0.85rem 1rem;
  border-radius: 14px;
  border: 1px solid transparent;
}

.flash--success {
  background: rgba(31, 95, 82, 0.1);
  border-color: rgba(31, 95, 82, 0.25);
}

.flash--error {
  background: rgba(158, 47, 47, 0.09);
  border-color: rgba(158, 47, 47, 0.25);
}

.form-error {
  color: var(--danger);
  font-size: 0.88rem;
}

.form-error--standalone {
  padding: 0.85rem 1rem;
  border: 1px solid rgba(158, 47, 47, 0.2);
  border-radius: 14px;
  background: rgba(158, 47, 47, 0.08);
}

.error-panel,
.empty-state {
  text-align: left;
}

.pagination {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.pagination__meta {
  color: var(--muted);
}

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

  .page-head,
  .topbar__inner {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar__actions {
    justify-content: space-between;
  }

  .memo-table th:nth-child(4),
  .memo-table td:nth-child(4) {
    display: none;
  }
}
