/* Palette inspired by OKI (o-k-i.net): warm gold accent, warm-tinted dark,
   cream text — plus a light theme. No pure black, for readability. */

:root,
:root[data-theme="dark"] {
  --bg: #1a0f1a; /* warm deep (OKI noir-profond) */
  --bg-2: #2d1b2e; /* OKI gris-sombre */
  --surface: #241626;
  --surface-2: #32203440;
  --border: #43314a;
  --text: #fff8e7; /* OKI blanc-crème */
  --muted: #b9a9bd;
  --accent: #fdb813; /* OKI or */
  --accent-strong: #ffd700; /* OKI jaune-soleil */
  --on-accent: #1a0f1a;
  --danger: #ff1654; /* OKI rouge */
  --success: #00d66c; /* OKI vert */
  --on-success: #06281a; /* dark text on the green toast */
  --radius: 14px;
}

:root[data-theme="light"] {
  --bg: #fff8e7; /* OKI blanc-crème */
  --bg-2: #f5f0e8;
  --surface: #ffffff;
  --surface-2: #f5f0e8;
  --border: #e3d8c8;
  --text: #1a0f1a;
  --muted: #6b5d63;
  --accent: #b87a00; /* OKI or assombri pour contraste */
  --accent-strong: #d99000;
  --on-accent: #fff8e7;
  --danger: #a01030;
  --success: #00a85b; /* OKI vert assombri pour le clair */
  --on-success: #ffffff;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(135deg, var(--bg) 0%, var(--bg-2) 100%) fixed;
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

a {
  color: inherit;
}

.container {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

.container.narrow {
  max-width: 420px;
}

/* ---------- Theme toggle ---------- */

.theme-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 10;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  font-size: 1.25rem;
  line-height: 1;
  padding: 0;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
}

.theme-toggle:hover {
  border-color: var(--accent);
}

/* ---------- Public page ---------- */

.hero {
  text-align: center;
  margin-bottom: 2.5rem;
}

.avatar {
  width: 112px;
  height: 112px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--border);
  margin: 0 auto 1rem;
  display: block;
  background: var(--surface);
}

.avatar.sm {
  width: 56px;
  height: 56px;
  border-width: 2px;
  margin: 0;
}

.avatar-current {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

label.inline {
  flex-direction: row;
  align-items: center;
  gap: 0.4rem;
  color: var(--text);
}

.site-footer {
  text-align: center;
  padding: 2rem 1.25rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.site-footer a {
  color: var(--accent);
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

.hero h1 {
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  margin: 0 0 0.25rem;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

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

.links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.9rem;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.link-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.link-card:hover {
  transform: translateY(-2px);
  border-color: var(--brand, var(--accent));
  background: var(--surface-2);
}

/* Display-only card (no URL): click/press to copy the ID. */
.link-card.copyable {
  cursor: pointer;
}

.link-card.copyable:active {
  transform: scale(0.99);
}

.copy-hint {
  margin-left: auto;
  display: grid;
  place-items: center;
  color: var(--muted);
  flex: none;
}

.copy-hint svg {
  width: 18px;
  height: 18px;
}

.link-card.copyable:hover .copy-hint {
  color: var(--brand, var(--accent));
}

/* Copy confirmation toast. */
.toast {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%) translateY(1rem);
  z-index: 20;
  max-width: calc(100% - 2rem);
  padding: 0.6rem 1rem;
  border-radius: 10px;
  background: var(--success);
  color: var(--on-success);
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.admin-meta .muted {
  color: var(--muted);
  font-size: 0.82rem;
  font-style: italic;
}

/* Brand-coloured chip with a white glyph: high contrast on either theme. */
.icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 10px;
  background: var(--brand, var(--accent));
  color: var(--brand-fg, #fff);
}

.icon svg {
  width: 24px;
  height: 24px;
}

/* Favicon image chip: neutral background so any icon stays legible. */
.icon.has-img {
  background: #fff;
  padding: 6px;
}

.icon.has-img img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 4px;
}

.icon.sm {
  width: 36px;
  height: 36px;
}

.icon.sm svg {
  width: 20px;
  height: 20px;
}

.meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.platform {
  font-weight: 600;
}

.label {
  color: var(--muted);
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty {
  text-align: center;
  color: var(--muted);
}

/* ---------- Cards / forms ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem;
  margin-bottom: 1.5rem;
}

.card h2 {
  margin-top: 0;
}

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

.grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr 1fr;
}

@media (max-width: 520px) {
  .grid {
    grid-template-columns: 1fr;
  }
}

label {
  display: grid;
  gap: 0.4rem;
  font-size: 0.9rem;
  color: var(--muted);
}

input,
select,
textarea {
  width: 100%;
  padding: 0.65rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.form h3 {
  margin: 0.5rem 0 -0.25rem;
  border-top: 1px solid var(--border);
  padding-top: 1.1rem;
}

button {
  padding: 0.65rem 1.1rem;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s ease;
}

button:hover {
  filter: brightness(1.08);
}

button.danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid color-mix(in srgb, var(--danger) 50%, transparent);
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
}

button.link-btn {
  background: none;
  color: var(--muted);
  padding: 0;
  font-weight: 400;
}

.error {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent);
  padding: 0.6rem 0.8rem;
  border-radius: 10px;
}

/* ---------- Admin ---------- */

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

.admin-header h1 {
  margin: 0;
}

.admin-header nav {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.admin-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.6rem;
}

.admin-list li {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.7rem 0.8rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.admin-list li.dragging {
  opacity: 0.5;
  border-color: var(--accent);
}

.handle {
  cursor: grab;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  user-select: none;
  flex: none;
}

.admin-list li:active .handle {
  cursor: grabbing;
}

.hint {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0.8rem 0 0;
}

.admin-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.admin-meta a {
  color: var(--accent);
  font-size: 0.82rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-list form {
  margin: 0;
}

.admin-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: none;
}

button.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 0.4rem 0.6rem;
  font-size: 1rem;
  line-height: 1;
}

button.ghost:hover {
  color: var(--accent);
  border-color: var(--accent);
}
