:root {
  --ink: #2a1f1a;
  --soft: #5c463c;
  --rose: #c45c4a;
  --rose-deep: #9e3d32;
  --paper: #fff7f0;
  --line: rgba(42, 31, 26, 0.1);
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "DM Sans", "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 18%, rgba(243, 199, 182, 0.55), transparent 42%),
    radial-gradient(circle at 88% 8%, rgba(217, 236, 228, 0.7), transparent 36%),
    linear-gradient(160deg, #fff9f4 0%, #f7ebe3 48%, #efe4dc 100%);
}
.wrap {
  width: min(520px, calc(100% - 1.5rem));
  margin: 0 auto;
  padding: 2rem 0 3.5rem;
}
.wrap.wide { width: min(760px, calc(100% - 1.5rem)); }
.brand {
  font-family: var(--font-display);
  font-size: clamp(1.55rem, 4vw, 1.85rem);
  margin: 0 0 0.25rem;
  letter-spacing: -0.02em;
}
.sub {
  color: var(--soft);
  margin: 0 0 1.5rem;
  line-height: 1.5;
  font-size: 0.95rem;
}
.card {
  background: rgba(255, 247, 240, 0.85);
  border: 1px solid rgba(42, 31, 26, 0.08);
  border-radius: 22px;
  padding: 1.15rem;
  box-shadow: 0 18px 50px rgba(42, 31, 26, 0.1);
}
label {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 0.9rem;
  font-size: 0.92rem;
  color: var(--soft);
}
input {
  width: 100%;
  border: 1px solid rgba(42, 31, 26, 0.12);
  border-radius: 14px;
  padding: 0.85rem 0.95rem;
  font: inherit;
  background: #fff;
  color: var(--ink);
}
.btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 0.75rem 1.15rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  font: inherit;
  font-weight: 500;
  background: var(--rose);
  color: #fff;
  white-space: nowrap;
  transition: background 0.15s ease, transform 0.15s ease;
}
.btn:hover { background: var(--rose-deep); }
.btn:active { transform: scale(0.98); }
.btn-ghost {
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn-ghost:hover { background: #fff; }
.btn-danger {
  background: transparent;
  color: var(--rose-deep);
  border: 1px solid rgba(158, 61, 50, 0.28);
}
.btn-danger:hover {
  background: #ffe8e4;
  color: #7a2d24;
}
.btn-sm {
  padding: 0.5rem 0.85rem;
  font-size: 0.84rem;
}
.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 1rem;
}
.err,
.ok {
  border-radius: 14px;
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.92rem;
  line-height: 1.45;
  word-break: break-word;
}
.err {
  background: #ffe8e4;
  color: #7a2d24;
}
.ok {
  background: #e7f6ee;
  color: #1f5b3a;
}
.hint { font-size: 0.85rem; color: var(--soft); }

/* Dashboard */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.15rem;
}
.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  flex-shrink: 0;
}
.list {
  display: grid;
  gap: 0.75rem;
}
.item {
  background: #fff;
  border-radius: 18px;
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  display: grid;
  gap: 0.85rem;
}
.item-main {
  display: grid;
  gap: 0.28rem;
  min-width: 0;
}
.item-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 650;
  line-height: 1.25;
  margin: 0;
}
.item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.65rem;
  color: var(--soft);
  font-size: 0.86rem;
}
.item-meta .dot {
  opacity: 0.45;
}
.link-row {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
  min-width: 0;
  background: rgba(255, 247, 240, 0.9);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.35rem 0.35rem 0.35rem 0.85rem;
}
.share-link {
  flex: 1;
  min-width: 0;
  color: var(--rose-deep);
  text-decoration: none;
  font-size: 0.88rem;
  line-height: 1.35;
  align-self: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.share-link:hover { text-decoration: underline; }
.item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}
.inline-form {
  display: contents;
}
.muted { color: var(--soft); font-size: 0.88rem; }
.empty {
  color: var(--soft);
  padding: 1.4rem 0.4rem;
  text-align: center;
}
.empty-actions {
  display: flex;
  justify-content: center;
  margin-top: 0.75rem;
}
.code-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  background: rgba(196, 92, 74, 0.1);
  color: var(--rose-deep);
  font-size: 0.8rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

@media (min-width: 640px) {
  .wrap { padding-top: 2.75rem; }
  .card { padding: 1.25rem; }
  .item {
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 1rem 1.25rem;
    padding: 1.1rem 1.2rem;
  }
  .item-main { grid-column: 1; }
  .link-row { grid-column: 1; }
  .item-actions {
    grid-column: 2;
    grid-row: 1 / span 2;
    flex-direction: column;
    align-items: stretch;
  }
  .item-actions .btn { width: 100%; }
}

@media (max-width: 639px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
  }
  .topbar-actions {
    width: 100%;
  }
  .topbar-actions .btn {
    flex: 1;
  }
  .item-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .item-actions .btn {
    width: 100%;
  }
  .link-row .btn {
    flex-shrink: 0;
  }
  .share-link {
    white-space: normal;
    word-break: break-all;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
}

@media (prefers-reduced-motion: reduce) {
  .btn { transition: none; }
}
