:root {
  --bg0: #f2f7f3;
  --bg1: #dceee1;
  --ink: #10241b;
  --muted: #4f665a;
  --line: #bfd8c8;
  --card: #f8fffa;
  --accent: #0f8a5f;
  --accent-2: #0d6d4b;
  --danger: #b73232;
  --shadow: 0 12px 35px rgba(20, 62, 44, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 10% 10%, var(--bg1), var(--bg0) 45%, #edf7ef 100%);
  overflow-x: hidden;
}

.bg-orb {
  position: fixed;
  z-index: -1;
  filter: blur(22px);
  opacity: 0.65;
}

.orb-a {
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: #8ed3ad;
  top: -50px;
  left: -60px;
}

.orb-b {
  width: 320px;
  height: 320px;
  border-radius: 50%;
  background: #a2d8ff;
  right: -80px;
  bottom: -80px;
}

.topbar {
  max-width: 1500px;
  margin: 0 auto;
  padding: 24px 18px 8px;
}

.topbar-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logout-link {
  border-radius: 10px;
  padding: 8px 12px;
  background: #1f6aa8;
  color: #fff;
  text-decoration: none;
  font-weight: 600;
}

.logout-link:hover {
  background: #155182;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(1.7rem, 2vw, 2.4rem);
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
}

.layout {
  max-width: 1500px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(290px, 0.85fr) minmax(420px, 1.25fr) minmax(460px, 1.35fr);
  gap: 16px;
  padding: 14px 18px 24px;
  align-items: start;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 16px;
  animation: rise 420ms ease-out both;
  min-width: 0;
}

.panel:nth-child(2) {
  animation-delay: 80ms;
}

.panel:nth-child(3) {
  animation-delay: 140ms;
}

h2,
h3 {
  margin-top: 0;
}

label {
  display: block;
  margin: 10px 0 6px;
  font-weight: 600;
}

input[type="text"],
input[type="search"],
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  font: inherit;
  background: #ffffff;
}

textarea,
pre,
code {
  font-family: "IBM Plex Mono", monospace;
}

textarea {
  resize: vertical;
}

button,
.import-json-label {
  border: none;
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

button:hover,
.import-json-label:hover {
  transform: translateY(-1px);
  background: var(--accent-2);
}

.secondary {
  background: #1f6aa8;
}

.danger {
  background: var(--danger);
}

.actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

#importJsonInput {
  display: none;
}

.divider {
  height: 1px;
  background: var(--line);
  margin: 16px 0;
}

.muted {
  color: var(--muted);
  font-size: 0.95rem;
}

.list-head {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

#snippetList {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: calc(100vh - 240px);
  min-height: 420px;
  overflow: auto;
}

#snippetList li {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 8px;
  cursor: pointer;
  background: #fff;
}

#snippetList li.active {
  border-color: var(--accent);
  outline: 2px solid rgba(15, 138, 95, 0.16);
}

.item-title {
  font-weight: 700;
}

.item-meta {
  color: var(--muted);
  font-size: 0.9rem;
}

.hidden {
  display: none;
}

.detail-top {
  display: flex;
  justify-content: flex-start;
  gap: 10px;
  align-items: baseline;
  flex-wrap: wrap;
}

#detailDate {
  color: var(--muted);
}

pre {
  border-radius: 10px;
  padding: 0;
  max-height: 56vh;
  overflow-x: auto;
  overflow-y: auto;
}

pre code {
  background: #101a15;
  color: #e5f6ee;
  display: inline-block;
  min-width: 100%;
  width: max-content;
  white-space: pre;
  border-radius: 6px;
  padding: 16px;
}

.toast {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #10241b;
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}

.auth-wrap {
  width: min(100%, 440px);
}

.auth-card {
  width: 100%;
  padding: 24px;
}

.auth-card h1 {
  margin-top: 0;
  margin-bottom: 8px;
}

.auth-form {
  margin-top: 14px;
}

.auth-form button {
  margin-top: 14px;
  width: 100%;
}

.auth-error {
  color: #b73232;
  font-weight: 600;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }

  #snippetList {
    max-height: 40vh;
    min-height: 220px;
  }

  pre {
    max-height: 42vh;
  }
}
