:root {
  --bg: #f7f2ea;
  --ink: #1f1b16;
  --muted: #6b6156;
  --accent: #e0543a;
  --accent-dark: #c4432c;
  --surface: #fff8f1;
  --card: #ffffff;
  --line: #efe3d6;
  --shadow: 0 10px 30px rgba(31, 27, 22, 0.08);
  --radius: 18px;
  --font: "Space Grotesk", "Poppins", "Avenir Next", sans-serif;
}

* { box-sizing: border-box; }

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: radial-gradient(1200px 600px at 10% -10%, #fbe7d3 0%, transparent 60%),
              radial-gradient(900px 500px at 110% 0%, #f2d3c7 0%, transparent 60%),
              var(--bg);
}

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

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  background: linear-gradient(180deg, rgba(255, 248, 241, 0.98) 0%, rgba(255, 248, 241, 0.92) 100%);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}

.header-title h1 {
  margin: 2px 0 0;
  font-size: 22px;
  letter-spacing: -0.02em;
}

.kicker {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--muted);
}

.icon-btn {
  border: none;
  background: var(--card);
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: var(--shadow);
}

.app-main {
  flex: 1;
  padding: 16px 18px 28px;
}

.screen { display: none; }
.screen.active { display: block; animation: fadeIn 220ms ease; }

.search-row {
  margin-bottom: 12px;
}

input[type="search"],
input[type="text"] {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--card);
  font-size: 16px;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 6px;
}

.card-sub {
  color: var(--muted);
  font-size: 13px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #f8e2d7;
  color: #8d3c2d;
  font-size: 12px;
  font-weight: 600;
}

.screen-meta {
  color: var(--muted);
  font-size: 13px;
  margin: 6px 0 14px;
}

.sticky-bar {
  position: sticky;
  top: 66px;
  z-index: 5;
  background: var(--bg);
  padding: 8px 0 6px;
}

.filter-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.filter-row label {
  font-size: 13px;
  color: var(--muted);
}

.filter-row select {
  flex: 1;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
  font-size: 14px;
}

.detail-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}

.detail-main h2 {
  margin: 0 0 6px;
  font-size: 20px;
}

.detail-meta {
  color: var(--muted);
  font-size: 13px;
}

.dot { margin: 0 6px; }

.thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  overflow: hidden;
  background: #f4efe7;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
}

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

.tag-editor {
  margin-top: 16px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  border: 1px dashed #e7cdbc;
}

.tag-input-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
}

.btn {
  border: none;
  border-radius: 12px;
  padding: 12px 14px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}

.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.success { background: #2e8b57; color: #fff; width: 100%; margin-top: 12px; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }

.speech-row {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.lang-toggle {
  display: flex;
  gap: 6px;
}

.pill {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
}

.pill.active {
  background: #1f1b16;
  color: #fff;
  border-color: #1f1b16;
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.tag {
  position: relative;
  padding: 6px 24px 6px 12px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  font-size: 13px;
  box-shadow: var(--shadow);
}

.tag button {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: #1f1b16;
  color: #fff;
  font-size: 12px;
  cursor: pointer;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 24px 0;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  background: #1f1b16;
  color: #fff;
  padding: 12px 16px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  font-size: 14px;
}

.loader {
  position: fixed;
  inset: 0;
  background: rgba(247, 242, 234, 0.75);
  display: grid;
  place-items: center;
  font-size: 16px;
  color: var(--muted);
}

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

@media (min-width: 720px) {
  .app-main { max-width: 640px; margin: 0 auto; }
}
