:root {
  color-scheme: light dark;
  --bg: #f5f5f7;
  --card-bg: #ffffff;
  --text: #1a1a1a;
  --muted: #666;
  --accent: #3462eb;
  --border: #e2e2e6;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 2rem;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.brand-logo {
  font-size: 1.6rem;
  line-height: 1;
}

.brand-title {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 600;
}

.brand-title em {
  font-family: "Caveat", "Brush Script MT", cursive;
  font-style: normal;
  font-weight: 600;
  color: var(--accent);
  font-size: 1.3em;
  margin-left: 0.1rem;
}

#lock-button {
  background: transparent;
  color: var(--muted);
  font-size: 1.1rem;
  padding: 0.4rem 0.55rem;
  border-radius: 8px;
  opacity: 0.7;
}

#lock-button:hover { opacity: 1; background: var(--bg); }

#auth-area {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.auth-username {
  font-size: 0.9rem;
  color: var(--muted);
}

button {
  border: none;
  border-radius: 6px;
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: white;
  font-size: 0.9rem;
  cursor: pointer;
}

button.secondary { background: transparent; color: var(--text); border: 1px solid var(--border); }

#admin-panel {
  padding: 1rem 2rem;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
}

#add-tile-form {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

#add-tile-form input {
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
  flex: 1;
  min-width: 180px;
}

.hidden { display: none !important; }

.tiles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.25rem;
  padding: 2rem;
}

.tile {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: var(--text);
  position: relative;
}

.tile-thumb-link { display: block; text-decoration: none; }

.tile img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  background: #eee;
  display: block;
}

.tile-placeholder {
  width: 100%;
  aspect-ratio: 16 / 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--muted);
  font-size: 0.85rem;
}

.tile-body { padding: 0.75rem 1rem; }
.tile-title { font-weight: 600; margin: 0 0 0.15rem; color: var(--text); }
.tile-url { margin: 0; font-size: 0.8rem; color: var(--muted); word-break: break-all; }

.tile-remove,
.tile-capture {
  position: absolute;
  top: 0.5rem;
  background: rgba(0,0,0,0.6);
  color: white;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
}

.tile-remove { right: 0.5rem; }
.tile-capture { right: 2.75rem; font-size: 0.85rem; }

dialog {
  border: none;
  border-radius: 10px;
  padding: 1.5rem;
  max-width: 320px;
  width: 90%;
}

dialog::backdrop { background: rgba(0,0,0,0.4); }

#login-form { display: flex; flex-direction: column; gap: 0.6rem; }
#login-form input {
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.dialog-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 0.5rem; }
.error { color: #c0392b; font-size: 0.85rem; margin: 0; }

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17181c;
    --card-bg: #202127;
    --text: #f0f0f2;
    --muted: #9a9aa2;
    --border: #35363d;
  }
}
