/* HTML Preview — studio light */

:root {
  --bg: #eef2ef;
  --bg-deep: #e2e8e3;
  --ink: #14241e;
  --ink-soft: #3d5248;
  --muted: #6b7f74;
  --line: rgba(20, 36, 30, 0.12);
  --line-strong: rgba(20, 36, 30, 0.22);
  --panel: rgba(255, 255, 255, 0.72);
  --panel-solid: #f7faf7;
  --accent: #c8f542;
  --accent-ink: #14241e;
  --danger: #c43232;
  --ok: #1f7a4c;
  --warn: #a86b12;
  --radius: 6px;
  --font: "Figtree", "Segoe UI", sans-serif;
  --display: "Syne", "Figtree", sans-serif;
  --topbar-h: 56px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html { font-size: 16px; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(1200px 600px at 12% -10%, rgba(200, 245, 66, 0.28), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(90, 140, 120, 0.18), transparent 50%),
    linear-gradient(165deg, #f4f7f4 0%, var(--bg) 42%, var(--bg-deep) 100%);
}

.atmosphere::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.35;
  background-image:
    linear-gradient(rgba(20, 36, 30, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(20, 36, 30, 0.04) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%);
}

.hidden { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* ── Shell ── */

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: var(--topbar-h);
  padding: 0 1.5rem;
  backdrop-filter: blur(14px);
  background: rgba(238, 242, 239, 0.78);
  border-bottom: 1px solid var(--line);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  min-width: 0;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.brand {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.03em;
  color: var(--ink);
  text-decoration: none;
  flex-shrink: 0;
}

.nav {
  display: flex;
  align-items: center;
  gap: 0.15rem;
}

.nav-link {
  padding: 0.4rem 0.7rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: var(--radius);
  transition: color 0.2s var(--ease), background 0.2s var(--ease);
}

.nav-link:hover { color: var(--ink); }
.nav-link.active {
  color: var(--ink);
  background: rgba(20, 36, 30, 0.06);
}

.main {
  flex: 1;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.75rem 1.5rem 4rem;
}

.main.drop-active {
  outline: 2px dashed var(--ink);
  outline-offset: -8px;
  background: rgba(200, 245, 66, 0.12);
  border-radius: 12px;
}

/* ── Buttons ── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.55rem 1.05rem;
  font-size: 0.9rem;
  font-family: inherit;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform 0.15s var(--ease), background 0.15s, border-color 0.15s, color 0.15s;
}

.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.drawer-preview a.card-thumb {
  display: block;
  width: 100%;
  height: 100%;
  color: inherit;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: rgba(20, 36, 30, 0.15);
  text-decoration: none;
}
.btn-primary:hover:not(:disabled) { filter: brightness(0.97); }

.btn-secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--line-strong);
}
.btn-secondary:hover:not(:disabled) { background: rgba(20, 36, 30, 0.04); }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: rgba(196, 50, 50, 0.35);
}
.btn-danger:hover:not(:disabled) { background: rgba(196, 50, 50, 0.08); }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: none;
  padding: 0.4rem 0.65rem;
  font-weight: 500;
}
.btn-ghost:hover:not(:disabled) { color: var(--ink); }

.btn-icon {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.45rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.2rem;
}
.btn-icon:hover { color: var(--ink); }

/* ── Forms ── */

.form-group { margin-bottom: 1rem; }

.form-group label {
  display: block;
  margin-bottom: 0.3rem;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
  text-transform: uppercase;
}

input[type="text"],
input[type="password"],
input[type="search"],
input[type="datetime-local"],
textarea,
select {
  width: 100%;
  padding: 0.65rem 0.8rem;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(200, 245, 66, 0.35);
}

textarea { resize: vertical; min-height: 72px; }

.form-error {
  margin-top: 0.45rem;
  font-size: 0.85rem;
  color: var(--danger);
}

/* ── Auth ── */

.auth-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  animation: rise 0.55s var(--ease) both;
}

.auth-panel {
  width: 100%;
  max-width: 380px;
}

.auth-panel .brand-mark {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(2rem, 5vw, 2.6rem);
  letter-spacing: -0.045em;
  line-height: 1;
  margin: 0 0 1.75rem;
  color: var(--ink);
}

.auth-panel .btn-primary { width: 100%; margin-top: 0.25rem; }

/* ── Home ── */

.home-stage {
  text-align: center;
  padding: 1.25rem 0 2rem;
  animation: rise 0.55s var(--ease) both;
}

.home-stage .brand-mark {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(2.4rem, 7vw, 4rem);
  letter-spacing: -0.05em;
  line-height: 0.95;
  margin: 0 0 1.5rem;
  color: var(--ink);
}

.home-controls {
  display: flex;
  align-items: stretch;
  justify-content: center;
  max-width: 560px;
  margin: 0 auto;
}

.home-controls .search-wrap { flex: 1; margin: 0; width: 100%; }

.search-wrap input[type="search"] {
  padding: 0.8rem 1rem;
  font-size: 1rem;
  background: #fff;
}

/* ── Grid ── */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 1.1rem;
}

.tile {
  background: transparent;
  padding: 0;
  text-align: left;
  color: inherit;
  animation: rise 0.45s var(--ease) both;
}

.tile:nth-child(1) { animation-delay: 0.02s; }
.tile:nth-child(2) { animation-delay: 0.05s; }
.tile:nth-child(3) { animation-delay: 0.08s; }
.tile:nth-child(4) { animation-delay: 0.11s; }
.tile:nth-child(5) { animation-delay: 0.14s; }
.tile:nth-child(6) { animation-delay: 0.17s; }

.tile-media {
  position: relative;
  display: block;
  aspect-ratio: 5 / 4;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--panel-solid);
  border: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
  transition: transform 0.35s var(--ease), border-color 0.2s;
}

.tile-media:hover,
.tile-media:focus-visible {
  transform: translateY(-3px) scale(1.01);
  border-color: var(--ink);
  outline: none;
}

.tile-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.tile-media picture {
  display: block;
  width: 100%;
  height: 100%;
}

.tile-caption {
  margin-top: 0.55rem;
}

.tile-caption-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
}

.tile-title {
  margin: 0;
  flex: 1;
  min-width: 0;
  font-family: var(--display);
  font-size: 0.98rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-tile-edit {
  flex-shrink: 0;
  margin: 0;
  padding: 0.15rem 0.45rem;
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.btn-tile-edit:hover {
  color: var(--ink);
  background: rgba(20, 36, 30, 0.04);
  border-color: var(--ink);
}

.tile-meta {
  margin: 0.15rem 0 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.tile-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.55rem;
}

.tile-actions .btn {
  flex: 1;
  font-size: 0.78rem;
  padding: 0.4rem 0.5rem;
}

.scroll-sentinel { height: 1px; margin-top: 1rem; }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  text-align: center;
  padding: 4rem 1.25rem 3.5rem;
  animation: rise 0.45s var(--ease) both;
}

.empty-icon {
  width: 4.5rem;
  height: 4.5rem;
  display: grid;
  place-items: center;
  margin-bottom: 0.35rem;
  color: var(--ink);
  background: rgba(200, 245, 66, 0.35);
  border: 1px solid var(--line-strong);
  border-radius: 1rem;
  transform: rotate(-3deg);
}

.empty-icon svg {
  width: 2.35rem;
  height: 2.35rem;
}

.empty-title {
  margin: 0;
  font-family: var(--display);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--ink);
}

.empty-hint {
  margin: 0;
  max-width: 16rem;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--muted);
}

.loading-more {
  text-align: center;
  padding: 1rem;
  color: var(--muted);
  font-size: 0.85rem;
}

/* ── Page header ── */

.page-header {
  margin-bottom: 1.25rem;
  animation: rise 0.4s var(--ease) both;
}

.page-header h1 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.6rem, 3vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.04em;
}

.page-toolbar {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 1.25rem;
  max-width: 420px;
}

.page-toolbar .search-wrap { flex: 1; margin: 0; }

/* ── Settings ── */

.settings-stack {
  display: grid;
  gap: 1.75rem;
  max-width: 640px;
  animation: rise 0.45s var(--ease) both;
}

.settings-block h2 {
  margin: 0 0 0.85rem;
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.info-list {
  margin: 0;
  display: grid;
  gap: 0.55rem;
}

.info-row {
  display: grid;
  grid-template-columns: 4.5rem 1fr;
  gap: 0.75rem;
  font-size: 0.9rem;
  align-items: baseline;
}

.info-row dt {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.info-row dd {
  margin: 0;
  word-break: break-all;
}

.info-row a {
  color: var(--ink);
  text-underline-offset: 2px;
}

.key-form-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.key-form-row input { flex: 1; }

.key-list {
  list-style: none;
  padding: 0;
  margin: 0;
  border-top: 1px solid var(--line);
}

.key-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--line);
}

.key-item-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.key-item-prefix {
  font-size: 0.78rem;
  color: var(--muted);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  margin-top: 0.15rem;
}

.key-reveal {
  margin-bottom: 0.85rem;
  padding: 0.85rem;
  background: #fff;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
}

.key-reveal code {
  display: block;
  word-break: break-all;
  font-size: 0.82rem;
  margin: 0.45rem 0 0.65rem;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}

.browser-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}

.browser-path {
  color: var(--muted);
  font-size: 0.8rem;
  font-family: ui-monospace, Menlo, monospace;
  word-break: break-all;
}

.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.82rem;
  font-weight: 600;
}

.status-dot::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: currentColor;
}

.status-dot.ok { color: var(--ok); }
.status-dot.warn { color: var(--warn); }
.status-dot.err { color: var(--danger); }

.status-badge {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.status-badge.ok { color: var(--ok); }
.status-badge.warn { color: var(--warn); }
.status-badge.err { color: var(--danger); }

/* ── Drawer ── */

.drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(20, 36, 30, 0.28);
  display: flex;
  justify-content: flex-end;
  backdrop-filter: blur(2px);
}

.drawer {
  width: 100%;
  max-width: 440px;
  height: 100%;
  background: var(--panel-solid);
  border-left: 1px solid var(--line-strong);
  display: flex;
  flex-direction: column;
  animation: slideIn 0.32s var(--ease);
}

@keyframes slideIn {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.15rem;
  border-bottom: 1px solid var(--line);
}

.drawer-header h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.15rem;
}

.drawer-preview {
  margin-bottom: 1rem;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  aspect-ratio: 16 / 10;
  background: var(--bg);
}

.drawer-preview .card-thumb,
.drawer-preview picture,
.drawer-preview img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.drawer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 1.1rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--line);
}

.screenshot-status {
  margin-bottom: 1rem;
  font-size: 0.85rem;
}

/* ── Toast ── */

.toast {
  position: fixed;
  bottom: 1.4rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  padding: 0.65rem 1.15rem;
  background: var(--ink);
  color: #f4f7f4;
  border-radius: var(--radius);
  font-size: 0.88rem;
  font-weight: 500;
  animation: fadeUp 0.25s var(--ease);
}

@keyframes fadeUp {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ── Compat aliases used by older class names ── */

.card-thumb {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-deep);
}

@media (max-width: 640px) {
  .topbar { padding: 0 0.85rem; gap: 0.5rem; }
  .topbar-left { gap: 0.65rem; }
  .brand { font-size: 0.92rem; }
  .nav-link { padding: 0.35rem 0.45rem; font-size: 0.82rem; }
  .topbar-right .btn-primary { padding: 0.45rem 0.75rem; font-size: 0.82rem; }
  .main { padding: 1.1rem 0.85rem 3rem; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.85rem; }
  .drawer { max-width: 100%; }
  .info-row { grid-template-columns: 1fr; gap: 0.15rem; }
}
