/* ============================================
   Notatnik Smaku — tokeny
   ============================================ */
:root {
  --bg: #15130f;
  --bg-elevated: #1a1712;
  --surface: #201c17;
  --surface-hover: #29241d;
  --border: #34302a;
  --border-soft: #26221c;

  --text: #f1eae0;
  --text-dim: #a89a87;
  --text-faint: #6f6558;

  --gold: #d4a954;
  --gold-soft: rgba(212, 169, 84, 0.14);
  --gold-soft-strong: rgba(212, 169, 84, 0.28);
  --wine: #9a4a4a;
  --danger: #c1594a;
  --danger-soft: rgba(193, 89, 74, 0.14);

  --radius-lg: 18px;
  --radius: 12px;
  --radius-sm: 8px;

  --shadow-card: 0 10px 30px rgba(0, 0, 0, 0.35);
  --shadow-modal: 0 20px 60px rgba(0, 0, 0, 0.5);

  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

body {
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(212, 169, 84, 0.06), transparent),
    repeating-linear-gradient(0deg, rgba(255,255,255,0.012) 0px, rgba(255,255,255,0.012) 1px, transparent 1px, transparent 3px);
  min-height: 100vh;
}

button, input, select, textarea {
  font-family: inherit;
  color: inherit;
}

a { color: var(--gold); }

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ============================================
   Layout shell
   ============================================ */
.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px 100px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 12px 0 18px;
  background: linear-gradient(var(--bg) 78%, transparent);
  margin-bottom: 8px;
}

.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.brand {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 28px;
  letter-spacing: -0.01em;
  margin: 0;
  color: var(--text);
}

.brand span {
  color: var(--gold);
  font-style: italic;
  font-weight: 500;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-name {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 0.02em;
}

/* ============================================
   Toolbar: search + sort
   ============================================ */
.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.search-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 14px;
  transition: border-color 0.15s var(--ease);
}

.search-wrap:focus-within {
  border-color: var(--gold);
}

.search-wrap .icon {
  width: 17px;
  height: 17px;
  color: var(--text-faint);
  flex-shrink: 0;
}

.search-wrap input {
  border: none;
  background: none;
  padding: 12px 0;
  font-size: 14.5px;
  color: var(--text);
  width: 100%;
  outline: none;
}

.search-wrap input::placeholder { color: var(--text-faint); }

/* remove native search decorations */
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }

#sortSelect {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 14px;
  font-size: 13.5px;
  color: var(--text-dim);
  min-width: 0;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23a89a87' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 30px;
  cursor: pointer;
}

/* ============================================
   Tag filters
   ============================================ */
.tag-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-chip {
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 7px 13px;
  border-radius: 100px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s var(--ease);
  white-space: nowrap;
}

.tag-chip:hover { border-color: var(--text-faint); color: var(--text); }

.tag-chip.active {
  background: var(--gold-soft-strong);
  border-color: var(--gold);
  color: var(--gold);
}

/* ============================================
   State blocks (loading / empty / error)
   ============================================ */
.state-block {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-dim);
}

.state-title {
  font-family: var(--font-display);
  font-size: 21px;
  color: var(--text);
  margin: 0 0 6px;
}

.state-sub {
  font-size: 14px;
  color: var(--text-dim);
  margin: 0 0 18px;
}

/* ============================================
   Grid + cards
   ============================================ */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 18px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s var(--ease), border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
  animation: card-in 0.4s var(--ease) backwards;
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.card:hover {
  transform: translateY(-3px);
  border-color: var(--border);
  box-shadow: var(--shadow-card);
}

.card-media {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--bg-elevated);
  overflow: hidden;
}

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

.card-media.no-image {
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-media.no-image svg {
  width: 36px;
  height: 36px;
  color: var(--border);
}

.score-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 46px;
  height: 46px;
  filter: drop-shadow(0 3px 8px rgba(0,0,0,0.5));
}

.score-badge svg { width: 100%; height: 100%; transform: rotate(-90deg); }

.score-bg {
  fill: rgba(21, 19, 15, 0.72);
  stroke: rgba(255,255,255,0.1);
  stroke-width: 1;
}

.score-fg {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.6s var(--ease);
}

.score-num {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.card-body {
  padding: 14px 16px 16px;
}

.card-name {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  margin: 0 0 8px;
  color: var(--text);
  line-height: 1.25;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.card-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--gold);
  background: var(--gold-soft);
  padding: 3px 8px;
  border-radius: 100px;
}

.card-desc {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.5;
  margin: 0 0 10px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-meta {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-faint);
  display: flex;
  justify-content: space-between;
  border-top: 1px solid var(--border-soft);
  padding-top: 8px;
}

/* ============================================
   FAB
   ============================================ */
.fab {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--gold);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(212, 169, 84, 0.35);
  transition: transform 0.15s var(--ease), box-shadow 0.15s var(--ease);
  z-index: 30;
}

.fab svg { width: 24px; height: 24px; color: #15130f; }

.fab:hover { transform: scale(1.06); box-shadow: 0 12px 30px rgba(212, 169, 84, 0.45); }
.fab:active { transform: scale(0.96); }

/* ============================================
   Buttons
   ============================================ */
.btn-primary {
  background: var(--gold);
  color: #15130f;
  border: none;
  border-radius: var(--radius-sm);
  padding: 11px 22px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s var(--ease);
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-block { width: 100%; }

.btn-ghost {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: var(--radius-sm);
  padding: 11px 20px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s var(--ease);
}
.btn-ghost:hover { border-color: var(--text-faint); color: var(--text); }

.btn-danger-text { color: var(--danger); border-color: transparent; padding-left: 4px; }
.btn-danger-text:hover { background: var(--danger-soft); border-color: transparent; }

.btn-danger {
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 11px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn-danger:hover { filter: brightness(1.1); }

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s var(--ease);
  flex-shrink: 0;
}
.icon-btn:hover { color: var(--text); border-color: var(--text-faint); }
.icon-btn svg { width: 16px; height: 16px; }

/* ============================================
   Modal
   ============================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 9, 6, 0.72);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
  animation: overlay-in 0.2s var(--ease);
}

@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%;
  max-width: 520px;
  max-height: 92vh;
  overflow-y: auto;
  padding: 22px 22px 28px;
  box-shadow: var(--shadow-modal);
  animation: modal-in 0.28s var(--ease);
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-small {
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: auto;
  margin-top: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.modal-header h2 {
  font-family: var(--font-display);
  font-size: 20px;
  margin: 0;
}

#confirmText {
  font-size: 15px;
  color: var(--text);
  margin: 0 0 4px;
  line-height: 1.5;
}

/* ============================================
   Form
   ============================================ */
.field { margin-bottom: 16px; }

.field-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.field-optional { text-transform: none; letter-spacing: 0; color: var(--text-faint); }

.rating-readout { color: var(--gold); font-size: 13px; }

input[type="text"], input[type="password"], textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  font-size: 14.5px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s var(--ease);
  resize: vertical;
}

input[type="text"]:focus, input[type="password"]:focus, textarea:focus {
  border-color: var(--gold);
}

input[type="range"] {
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  appearance: none;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--gold);
  cursor: pointer;
  border: 3px solid var(--bg-elevated);
  box-shadow: 0 0 0 1px var(--gold);
}

input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--gold);
  cursor: pointer;
  border: 3px solid var(--bg-elevated);
  box-shadow: 0 0 0 1px var(--gold);
}

.tag-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 22px;
}

.spacer { flex: 1; }

/* image drop */
.image-drop {
  position: relative;
  aspect-ratio: 16 / 9;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.15s var(--ease);
}

.image-drop:hover, .image-drop.drag-over { border-color: var(--gold); }

.image-drop img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.drop-hint {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--text-faint);
  font-size: 13px;
  text-align: center;
  padding: 0 20px;
}

.drop-hint svg { width: 28px; height: 28px; }

.image-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(10, 9, 6, 0.7);
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.image-remove svg { width: 15px; height: 15px; }

/* ============================================
   Toast
   ============================================ */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  box-shadow: var(--shadow-card);
  z-index: 60;
  animation: toast-in 0.25s var(--ease);
  max-width: 90vw;
}

.toast.error { border-color: var(--danger); color: #f3b5aa; }

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

/* ============================================
   Auth screen
   ============================================ */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  box-shadow: var(--shadow-card);
}

.auth-brand {
  text-align: center;
  margin-bottom: 24px;
  font-size: 26px;
}

.auth-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 22px;
}

.auth-tab {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-faint);
  padding: 9px 0;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s var(--ease);
}

.auth-tab.active { background: var(--surface-hover); color: var(--text); }

.auth-error {
  font-size: 13px;
  color: var(--danger);
  background: var(--danger-soft);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin: -4px 0 14px;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 640px) {
  .app { padding: 16px 14px 90px; }
  .brand { font-size: 24px; }
  .toolbar { flex-direction: column; }
  #sortSelect { width: 100%; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .card-name { font-size: 15px; }
  .modal { padding: 18px 16px 24px; max-height: 96vh; }
  .fab { right: 16px; bottom: 16px; }
}

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