/* ============================================================================
   DaisyPaste — premium dark-first theme
   ========================================================================== */

:root {
  --bg: #120a16;
  --bg-2: #170e1d;
  --surface: rgba(255, 255, 255, 0.028);
  --surface-2: rgba(255, 255, 255, 0.045);
  --surface-hover: rgba(255, 255, 255, 0.07);
  --code-bg: #150a18;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);

  --text: #f4eef6;
  --text-dim: #bbabc8;
  --text-faint: #87778f;

  --pink: #ff80c5;
  --pink-strong: #ff58af;
  --purple: #c4a7f5;
  --teal: #66e0c8;
  --danger: #ff5c8a;
  --warn: #ffc07a;

  --ring: rgba(255, 128, 197, 0.45);
  --grad: linear-gradient(135deg, #ff80c5, #c4a7f5);

  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", "Fira Code", Menlo, Consolas, monospace;

  --radius: 14px;
  --radius-sm: 9px;
  --radius-lg: 22px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --shadow-sm: 0 6px 18px rgba(0, 0, 0, 0.3);
  --maxw: 1040px;
}

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

/* The `hidden` attribute must always win over component display rules
   (palette, options panel, modals, search bar, recent list, …). */
[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: 15.5px;
  line-height: 1.55;
  color: var(--text);
  background: radial-gradient(900px 500px at 50% -8%, rgba(255, 128, 197, 0.16), transparent 60%),
    radial-gradient(700px 500px at 90% 0%, rgba(196, 167, 245, 0.1), transparent 55%), var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection {
  background: rgba(255, 128, 197, 0.3);
}

a {
  color: var(--pink);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

.muted {
  color: var(--text-dim);
}
.icon {
  flex: 0 0 auto;
  vertical-align: middle;
}
.icon-sm {
  width: 16px;
  height: 16px;
}

kbd {
  font-family: var(--font-mono);
  font-size: 0.8em;
  padding: 1px 6px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text-dim);
}

/* ---- buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 550;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.12s ease, box-shadow 0.16s
    ease;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  text-decoration: none;
}
.btn:active {
  transform: translateY(1px);
}
.btn:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}
.btn-ghost {
  background: transparent;
}
.btn-icon {
  padding: 8px;
}
.btn-primary {
  color: #2a0b22;
  background: var(--grad);
  border: none;
  font-weight: 650;
  box-shadow: 0 8px 22px rgba(255, 88, 175, 0.28);
}
.btn-primary:hover {
  box-shadow: 0 10px 28px rgba(255, 88, 175, 0.4);
  filter: brightness(1.04);
}
.btn-danger {
  color: #fff;
  background: linear-gradient(135deg, #ff6a6a, #ff5c8a);
  border: none;
  font-weight: 650;
}
.btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}
.kbd-hint {
  margin-left: 2px;
  padding: 1px 6px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.4;
  color: #2a0b22;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(0, 0, 0, 0.14);
  border-radius: 5px;
}
.btn.flash {
  background: rgba(102, 224, 200, 0.18);
  border-color: rgba(102, 224, 200, 0.5);
}

/* ---- form controls ---- */
.input,
.select,
.title-input,
.code-input {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}
.input:focus,
.select:focus,
.title-input:focus,
.code-input:focus {
  border-color: var(--ring);
  box-shadow: 0 0 0 3px rgba(255, 128, 197, 0.14);
}
.select {
  cursor: pointer;
  appearance: none;
  padding-right: 26px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%),
    linear-gradient(135deg, var(--text-dim) 50%, transparent 50%);
  background-position: calc(100% - 14px) 52%, calc(100% - 9px) 52%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.select option {
  background: var(--bg-2);
}

/* ---- top bar ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 18px 22px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
}
.brand:hover {
  text-decoration: none;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  color: var(--pink);
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.brand-name {
  font-weight: 700;
  font-size: 1.12rem;
  letter-spacing: -0.01em;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---- page shell ---- */
.page {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 12px 22px 64px;
}
.section-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-dim);
  margin: 28px 0 12px;
}

/* ---- hero ---- */
.hero {
  text-align: center;
  padding: 30px 0 26px;
}
.hero-title {
  font-size: clamp(1.9rem, 4.5vw, 3rem);
  line-height: 1.08;
  letter-spacing: -0.025em;
  margin: 0 0 14px;
  font-weight: 760;
}
.hero-title .accent {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero-sub {
  max-width: 620px;
  margin: 0 auto;
  color: var(--text-dim);
  font-size: 1.02rem;
}

/* ---- editor ---- */
.editor {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  backdrop-filter: blur(8px);
}
.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.title-input {
  flex: 1 1 200px;
  min-width: 120px;
  font-weight: 600;
  font-size: 1rem;
  background: transparent;
  border-color: transparent;
}
.title-input:focus {
  background: var(--surface);
  border-color: var(--ring);
}
.toolbar-spacer {
  flex: 1 1 auto;
}
.field-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-dim);
}
.name-input {
  flex: 0 1 160px;
}

.editor-body {
  position: relative;
  display: flex;
  background: var(--code-bg);
}
.gutter {
  flex: 0 0 auto;
  width: 3.2ch;
  padding: 18px 10px 18px 0;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-faint);
  white-space: pre;
  user-select: none;
  overflow: hidden;
  border-right: 1px solid var(--border);
}
.code-input {
  flex: 1;
  min-height: 52vh;
  padding: 18px 16px;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.6;
  resize: vertical;
  tab-size: 2;
  caret-color: var(--pink);
}
.code-input:focus {
  box-shadow: none;
}

.options-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 20px;
  padding: 16px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-dim);
}
.check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.92rem;
  cursor: pointer;
}
.check input {
  width: 17px;
  height: 17px;
  accent-color: var(--pink-strong);
}
.check em {
  color: var(--text-faint);
  font-style: normal;
  font-size: 0.85em;
}
.check span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.editor-statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
}
.counts {
  font-size: 0.85rem;
  font-family: var(--font-mono);
}
.status-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.error-text {
  color: var(--danger);
  font-size: 0.86rem;
}

/* ---- recent ---- */
.recent-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}
.recent-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
}
.recent-item:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
  text-decoration: none;
}
.recent-title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.recent-meta {
  font-size: 0.8rem;
  color: var(--text-faint);
  font-family: var(--font-mono);
}

/* ---- paste view ---- */
.paste-head {
  margin: 14px 0 16px;
}
.paste-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.paste-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
  word-break: break-word;
}
.badges {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  font-size: 0.78rem;
  font-weight: 550;
  border-radius: 100px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.badge-lang {
  color: var(--purple);
}
.badge-warn {
  color: var(--warn);
  border-color: rgba(255, 192, 122, 0.35);
}
.badge-danger {
  color: var(--danger);
  border-color: rgba(255, 92, 138, 0.35);
}
.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 10px;
  font-size: 0.86rem;
  align-items: center;
}
.meta-row .expiry {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--warn);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  border-bottom: none;
}
.toolbar .btn {
  padding: 7px 11px;
  font-size: 0.86rem;
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-bottom: none;
}
.search-bar .input {
  flex: 1;
  background: var(--bg-2);
}
.search-bar #search-count {
  font-size: 0.82rem;
  font-family: var(--font-mono);
  min-width: 70px;
  text-align: right;
}

/* ---- code region ---- */
.code-region {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  overflow: hidden;
}
.file-tabs {
  display: flex;
  gap: 2px;
  padding: 8px 8px 0;
  background: var(--surface);
  overflow-x: auto;
}
.file-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font: inherit;
  font-size: 0.85rem;
  font-family: var(--font-mono);
  color: var(--text-dim);
  background: transparent;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  white-space: nowrap;
}
.file-tab.active {
  color: var(--text);
  background: var(--code-bg);
  border-color: var(--border);
}
.file-tab-close {
  border: none;
  background: none;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 1.1em;
  line-height: 1;
  padding: 0 2px;
}
.file-tab-close:hover {
  color: var(--danger);
}
.code-pane {
  display: none;
}
.code-pane.active {
  display: block;
}

.code-wrap {
  overflow: auto;
}
.code-wrap pre.shiki {
  margin: 0;
  padding: 18px 18px 18px 0;
  background: transparent !important;
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.6;
  tab-size: 2;
}
.code-wrap code {
  counter-reset: line;
  display: block;
  font-family: inherit;
}
.code-wrap .line {
  counter-increment: line;
  display: inline-block;
  width: 100%;
  padding: 0 16px 0 0;
}
.code-wrap .line::before {
  content: counter(line);
  display: inline-block;
  width: 3.2ch;
  margin-right: 18px;
  padding-right: 10px;
  text-align: right;
  color: var(--text-faint);
  border-right: 1px solid var(--border);
  user-select: none;
  position: sticky;
  left: 0;
}
.code-region.wrap .code-wrap pre.shiki,
.code-region.wrap .code-wrap .line {
  white-space: pre-wrap;
  word-break: break-word;
}
pre.shiki.plain {
  color: var(--text);
}
.search-hit {
  background: rgba(255, 192, 122, 0.28);
  color: inherit;
  border-radius: 3px;
}
.search-hit.current {
  background: var(--pink);
  color: #2a0b22;
}

/* ---- markdown preview ---- */
.markdown-body {
  padding: 20px 30px 30px;
  max-width: 80ch;
  line-height: 1.7;
}
.markdown-body > :first-child {
  margin-top: 0;
}
.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
  letter-spacing: -0.01em;
  margin-top: 1.5em;
}
.markdown-body h1 {
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.3em;
}
.markdown-body hr {
  margin: 1.8em 0;
  border: none;
  border-top: 1px solid var(--border);
}
.markdown-body code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 6px;
}
.markdown-body pre {
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  overflow: auto;
}
.markdown-body pre code {
  background: none;
  padding: 0;
  font-size: 0.9em;
}
.markdown-body blockquote {
  margin: 1em 0;
  padding-left: 1em;
  border-left: 3px solid var(--pink);
  color: var(--text-dim);
}
.markdown-body table {
  border-collapse: collapse;
}
.markdown-body th,
.markdown-body td {
  border: 1px solid var(--border);
  padding: 6px 12px;
}

/* ---- diff ---- */
.diff-view {
  overflow: auto;
}
.diff-head {
  display: flex;
  gap: 20px;
  padding: 10px 18px;
  font-family: var(--font-mono);
  font-size: 0.84rem;
  border-bottom: 1px solid var(--border);
}
.diff-from {
  color: var(--danger);
}
.diff-to {
  color: var(--teal);
}
.diff-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.55;
}
.diff-ln {
  width: 1%;
  padding: 0 8px;
  text-align: right;
  color: var(--text-faint);
  user-select: none;
  white-space: nowrap;
}
.diff-sign {
  width: 1%;
  padding: 0 6px;
  text-align: center;
  user-select: none;
}
.diff-text {
  padding: 0 12px;
  white-space: pre-wrap;
  word-break: break-word;
}
.diff-insert {
  background: rgba(102, 224, 200, 0.1);
}
.diff-insert .diff-sign,
.diff-insert .diff-text {
  color: var(--teal);
}
.diff-delete {
  background: rgba(255, 92, 138, 0.1);
}
.diff-delete .diff-sign,
.diff-delete .diff-text {
  color: var(--danger);
}

/* ---- decrypt panel ---- */
.decrypt-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
  padding: 48px 24px;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
}
.decrypt-panel .icon {
  width: 40px;
  height: 40px;
  color: var(--warn);
}
.decrypt-form {
  display: flex;
  gap: 8px;
}

/* ---- share modal & palette ---- */
.modal-backdrop,
.palette-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  background: rgba(8, 4, 11, 0.65);
  backdrop-filter: blur(6px);
  animation: fade 0.15s ease;
}
.modal-backdrop {
  place-items: center;
  padding: 22px;
}
.palette-backdrop {
  place-items: start center;
  padding: 12vh 22px 22px;
}
.modal {
  width: min(440px, 100%);
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 22px;
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-head h2 {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 1.1rem;
  margin: 0;
}
.copy-row {
  display: flex;
  gap: 8px;
}
.copy-row .input {
  flex: 1;
}
.qr-box {
  display: grid;
  place-items: center;
  padding: 16px;
  background: #fff;
  border-radius: var(--radius-sm);
}
.qr-box svg {
  width: 180px;
  height: 180px;
  display: block;
}

.palette {
  width: min(560px, 100%);
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.palette-input {
  width: 100%;
  padding: 16px 18px;
  font-size: 1rem;
  color: var(--text);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  outline: none;
}
.palette-list {
  list-style: none;
  margin: 0;
  padding: 6px;
  max-height: 50vh;
  overflow: auto;
}
.palette-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.palette-item.active {
  background: var(--surface-hover);
}
.palette-hint {
  font-size: 0.75rem;
  color: var(--text-faint);
  font-family: var(--font-mono);
}

/* ---- status / 404 pages ---- */
.page-status {
  display: grid;
  place-items: center;
  min-height: 64vh;
}
.status-card {
  text-align: center;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.status-card h1 {
  font-size: 1.5rem;
  margin: 0;
}
.status-glyph {
  display: grid;
  place-items: center;
  width: 84px;
  height: 84px;
  border-radius: 22px;
  color: var(--pink);
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.status-glyph .icon {
  width: 42px;
  height: 42px;
}
.status-glyph.burning {
  color: var(--warn);
}

/* ---- footer ---- */
.site-footer {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 28px 22px 36px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  border-top: 1px solid var(--border);
  font-size: 0.86rem;
  color: var(--text-dim);
}
.site-footer > span:first-child {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

@keyframes fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ---- responsive ---- */
@media (max-width: 680px) {
  body {
    font-size: 15px;
  }
  .page,
  .topbar,
  .site-footer {
    padding-left: 16px;
    padding-right: 16px;
  }
  .options-panel {
    grid-template-columns: 1fr;
  }
  .toolbar .btn span:not(.kbd-hint),
  .brand-name {
    /* keep labels; icons remain */
  }
  .editor-statusbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .status-actions {
    justify-content: space-between;
  }
  .hero {
    padding: 18px 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* ============================================================
   v2 — accounts, auth, dashboard
   ============================================================ */

.btn-danger-ghost:hover {
  border-color: color-mix(in srgb, var(--danger) 55%, transparent);
  color: var(--danger);
}

/* --- auth / login --- */
.page-auth {
  display: flex;
  justify-content: center;
  padding: clamp(2rem, 6vw, 5rem) 1.25rem;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 2rem;
  text-align: center;
}
.auth-mark {
  width: 56px;
  height: 56px;
  margin: 0 auto 0.75rem;
  display: grid;
  place-items: center;
  color: #1b0f20;
  background: linear-gradient(135deg, var(--pink), var(--purple));
  border-radius: 16px;
  font-weight: 800;
  font-size: 1.4rem;
  letter-spacing: -0.5px;
}
.auth-card h1 {
  font-size: 1.4rem;
  margin: 0.25rem 0 0.4rem;
}
.auth-form {
  margin-top: 1.5rem;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.auth-actions {
  display: flex;
  gap: 0.6rem;
}
.auth-actions .btn {
  flex: 1;
  justify-content: center;
}
.auth-note {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  text-align: left;
  color: var(--text-faint);
  font-size: 0.82rem;
}
.auth-note .icon {
  flex: none;
  color: var(--purple);
}

/* --- dashboard --- */
.page-dashboard {
  display: grid;
  grid-template-columns: 248px 1fr;
  gap: 1.5rem;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1.5rem 1.25rem 4rem;
  align-items: start;
}
.dash-sidebar {
  position: sticky;
  top: 88px;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}
.dash-side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.dash-sidebar h2 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  margin: 0.5rem 0 0.25rem;
}
.dash-folders {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.dash-folders li {
  display: flex;
  align-items: center;
}
.folder-link {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.6rem;
  border-radius: var(--radius-sm);
  background: none;
  border: 0;
  color: var(--text-dim);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.folder-link:hover {
  background: var(--surface-hover);
  color: var(--text);
}
.folder-link.active {
  background: color-mix(in srgb, var(--pink) 16%, transparent);
  color: var(--text);
}
.folder-del {
  opacity: 0;
  transition: opacity 0.15s;
}
.dash-folders li:hover .folder-del {
  opacity: 0.6;
}
.dash-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.dash-account {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.dash-account .btn {
  justify-content: flex-start;
}

.dash-main {
  min-width: 0;
}
.dash-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.5rem;
}
.dash-toolbar h1 {
  font-size: 1.5rem;
  margin: 0;
}
.search-inline,
.field-inline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 0.65rem;
  color: var(--text-faint);
}
.search-inline .input {
  border: 0;
  background: none;
  padding: 0.5rem 0;
}
.dash-list {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.dash-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 0.9rem;
  transition: border-color 0.15s, background 0.15s;
}
.dash-card:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
}
.dash-card-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  text-decoration: none;
  color: inherit;
}
.dash-card-title {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dash-card-meta {
  font-size: 0.8rem;
}
.dash-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.25rem;
}
.dash-card-actions {
  display: flex;
  gap: 0.2rem;
  flex: none;
}
.chip {
  font-size: 0.72rem;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.chip-btn {
  cursor: pointer;
}
.chip-btn.active {
  background: color-mix(in srgb, var(--pink) 22%, transparent);
  color: var(--text);
  border-color: transparent;
}
.vis {
  font-weight: 600;
}
.vis-private {
  color: var(--warn);
}
.vis-unlisted {
  color: var(--purple);
}
.vis-public {
  color: var(--teal);
}
.dash-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-faint);
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 0.5rem;
}

@media (max-width: 760px) {
  .page-dashboard {
    grid-template-columns: 1fr;
  }
  .dash-sidebar {
    position: static;
  }
  .dash-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
}

/* ============================================================
   v3 — account menu + avatars
   ============================================================ */
.account-menu {
  position: relative;
}
.account-trigger {
  display: grid;
  place-items: center;
  padding: 3px;
  background: none;
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.15s ease;
}
.account-trigger:hover {
  border-color: var(--border-strong);
}
.account-trigger:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}
.avatar {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.82rem;
  color: #1b0f20;
  overflow: hidden;
  flex: none;
  object-fit: cover;
}
.account-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 232px;
  z-index: 200;
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 6px;
  animation: fade 0.12s ease;
}
.account-head {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 8px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
.account-name {
  font-weight: 600;
}
.account-handle {
  font-size: 0.8rem;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: none;
  border: 0;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  text-decoration: none;
}
.menu-item:hover {
  background: var(--surface-hover);
  text-decoration: none;
}
.menu-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 4px;
}

/* ---- settings page ---- */
.page-settings {
  max-width: 680px;
}
.settings-title {
  font-size: 1.6rem;
  margin: 8px 0 20px;
}
.settings-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
}
.settings-h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.05rem;
  margin: 0 0 6px;
}
.settings-identity {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}
.settings-identity .avatar {
  width: 56px;
  height: 56px;
  font-size: 1.4rem;
}
.settings-card .field {
  margin-bottom: 14px;
}
.settings-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
}
.settings-actions .muted {
  margin-right: auto;
  font-size: 0.85rem;
}
.device-list {
  list-style: none;
  margin: 12px 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.device {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.device-name {
  font-weight: 600;
}
.device-date {
  margin-left: auto;
  font-size: 0.82rem;
}
.danger-zone {
  border-color: color-mix(in srgb, var(--danger) 35%, var(--border));
}

/* ---- line links ---- */
.code-wrap .line.line-hl {
  background: rgba(255, 128, 197, 0.12);
  box-shadow: inset 3px 0 0 var(--pink);
}
.code-wrap .line::before {
  cursor: pointer;
}
.code-wrap .line:hover::before {
  color: var(--pink);
}

/* ============================================================
   v3 — light theme (page chrome lightens; code panels stay dark
   so the daisy-dark Shiki tokens remain readable)
   ============================================================ */
[data-theme="light"] {
  --bg: #f7f4f9;
  --bg-2: #ffffff;
  --surface: rgba(20, 8, 24, 0.03);
  --surface-2: rgba(20, 8, 24, 0.05);
  --surface-hover: rgba(20, 8, 24, 0.07);
  --border: rgba(20, 8, 24, 0.1);
  --border-strong: rgba(20, 8, 24, 0.2);
  --text: #1b0f20;
  --text-dim: #574c61;
  --text-faint: #877f92;
  --pink-strong: #d6379a;
  --shadow: 0 18px 50px rgba(80, 40, 90, 0.16);
  --shadow-sm: 0 6px 18px rgba(80, 40, 90, 0.12);
}
[data-theme="light"] body {
  background: radial-gradient(900px 500px at 50% -8%, rgba(255, 128, 197, 0.1), transparent 60%),
    radial-gradient(700px 500px at 90% 0%, rgba(196, 167, 245, 0.08), transparent 55%), var(--bg);
}
[data-theme="light"] .btn-primary,
[data-theme="light"] .kbd-hint {
  color: #2a0b22;
}
/* Code areas adapt to the theme (light panel in light mode). Tokens carry both
   --shiki-light and --shiki-dark; we pick the set per theme. */
[data-theme="light"] {
  --code-bg: #faf7fc;
}
[data-theme="light"] .code-input::placeholder {
  color: #9a8fa6;
}
.shiki,
.shiki span {
  color: var(--shiki-dark, var(--text));
}
[data-theme="light"] .shiki,
[data-theme="light"] .shiki span {
  color: var(--shiki-light, var(--text));
}

/* ============================================================
   v4 — invite-only posting: logged-out gate + admin invite list
   ============================================================ */
.post-gate {
  display: flex;
  justify-content: center;
  margin-top: 1.5rem;
}
.gate-card {
  max-width: 460px;
  width: 100%;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 2.25rem 1.75rem;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.gate-icon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 18px;
  color: var(--pink);
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.gate-icon .icon {
  width: 30px;
  height: 30px;
}
.gate-card h2 {
  margin: 0;
  font-size: 1.3rem;
}
.gate-card p {
  margin: 0;
  line-height: 1.5;
}
.gate-actions {
  margin-top: 0.4rem;
}
.gate-note {
  font-size: 0.85rem;
}

.invite-new {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 0.5rem 0 0.75rem;
}
.invite-new .input {
  flex: 1 1 200px;
}
.invite-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.invite {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.7rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.invite[data-used="1"] {
  opacity: 0.62;
}
.invite-code {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--text);
  background: var(--surface-2);
  padding: 0.15rem 0.5rem;
  border-radius: 7px;
}
.invite-meta {
  flex: 1;
  font-size: 0.85rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.invite-empty {
  margin: 0.25rem 0 0;
  font-size: 0.9rem;
}
