:root {
  --bg: #0b0a09;
  --surface: #1a1715;
  --surface-2: #131110;
  --surface-hi: #221d19;
  --text: #f6f2ee;
  --text-2: #b3a89f;
  --text-3: #7d7168;
  --line: rgba(255, 180, 120, 0.10);
  --line-strong: rgba(255, 180, 120, 0.20);
  --accent: #ff7a1a;
  --accent-soft: #ffa24a;
  --accent-grad: linear-gradient(135deg, #ffb24a 0%, #ff7a1a 48%, #ff4d2e 100%);
  --glow: 0 8px 30px rgba(255, 100, 25, 0.35);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 12px 34px rgba(0, 0, 0, 0.55);
  --shadow-hover: 0 2px 8px rgba(0, 0, 0, 0.5), 0 24px 60px rgba(0, 0, 0, 0.7), 0 0 0 1px var(--line-strong);
  --radius: 20px;
  --radius-sm: 13px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  letter-spacing: -0.01em;
  min-height: 100vh;
}

.ambient {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(58vw 44vh at 14% -12%, rgba(255, 138, 30, 0.20), transparent 60%),
    radial-gradient(50vw 42vh at 104% 4%, rgba(255, 77, 46, 0.14), transparent 58%),
    radial-gradient(70vw 60vh at 50% 118%, rgba(255, 122, 26, 0.10), transparent 60%);
}

.logo-glyph {
  width: 100%; height: 100%;
  -webkit-mask: url("icon.svg") center/64% no-repeat;
  mask: url("icon.svg") center/64% no-repeat;
  background: #fff;
  display: block;
}

.wrap { width: 100%; max-width: 1140px; margin: 0 auto; padding: 0 24px; position: relative; z-index: 1; }

/* ---------- Auth ---------- */
.auth {
  position: fixed; inset: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.auth-card {
  position: relative; z-index: 1;
  width: 100%; max-width: 380px;
  padding: 40px 34px 26px;
  text-align: center;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  border: 1px solid var(--line);
  border-radius: 26px;
  box-shadow: var(--shadow);
  backdrop-filter: saturate(160%) blur(24px);
  -webkit-backdrop-filter: saturate(160%) blur(24px);
  animation: rise 0.5s cubic-bezier(0.2,0.7,0.2,1) both;
}
.auth-mark {
  width: 62px; height: 62px; margin: 0 auto 18px;
  border-radius: 18px; background: var(--accent-grad);
  box-shadow: var(--glow); display: flex; align-items: center; justify-content: center;
}
.auth-mark .logo-glyph { background: rgba(0,0,0,0.85); }
.auth-title { margin: 0; font-size: 26px; font-weight: 600; letter-spacing: -0.03em; }
.auth-sub { margin: 6px 0 26px; font-size: 15px; color: var(--text-2); }
#auth-form { display: flex; flex-direction: column; gap: 10px; }
.field {
  height: 50px; padding: 0 16px;
  font-size: 16px; font-family: inherit; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
}
.field::placeholder { color: var(--text-3); }
.field:focus {
  border-color: color-mix(in srgb, var(--accent) 65%, transparent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent);
}
.auth-error {
  margin: 14px 0 0; font-size: 13.5px; color: #ff6b5a;
  background: color-mix(in srgb, #ff6b5a 12%, transparent);
  border-radius: 10px; padding: 9px 12px;
}
.auth-divider {
  display: flex; align-items: center; gap: 12px;
  margin: 18px 0 14px; color: var(--text-3); font-size: 12.5px;
}
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.btn-google {
  width: 100%; height: 50px; display: flex; align-items: center; justify-content: center; gap: 10px;
  font-size: 15.5px; font-weight: 500; font-family: inherit; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  cursor: pointer; transition: background 0.15s, border-color 0.15s;
}
.btn-google:hover { background: var(--surface-hi); border-color: var(--accent-soft); }
.g-icon { width: 18px; height: 18px; flex: none; }

.auth-switch {
  margin-top: 20px; padding: 6px; width: 100%;
  font-size: 14px; font-family: inherit; color: var(--text-2);
  background: none; border: none; cursor: pointer;
}
.auth-switch b { color: var(--accent-soft); font-weight: 600; }

/* ---------- Accent button ---------- */
.btn-accent {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  height: 50px; padding: 0 26px;
  font-size: 16px; font-weight: 550; font-family: inherit; color: #1a0d04;
  background: var(--accent-grad); border: none; border-radius: var(--radius-sm);
  cursor: pointer; white-space: nowrap;
  box-shadow: var(--glow);
  transition: transform 0.12s, filter 0.18s, opacity 0.18s;
}
.btn-accent:hover { filter: brightness(1.07) saturate(1.05); }
.btn-accent:active { transform: scale(0.975); }
.btn-accent[disabled] { opacity: 0.6; cursor: default; }
.btn-accent.is-loading .btn-label { opacity: 0; }
.btn-accent.is-loading::after {
  content: ""; position: absolute; width: 18px; height: 18px;
  border: 2px solid rgba(26,13,4,0.35); border-top-color: #1a0d04;
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  border-bottom: 1px solid var(--line);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 62px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 9px; background: var(--accent-grad);
  box-shadow: var(--glow); display: flex; align-items: center; justify-content: center;
}
.brand-mark .logo-glyph { background: rgba(0,0,0,0.82); }
.brand h1 { margin: 0; font-size: 19px; font-weight: 600; letter-spacing: -0.02em; }
.topbar-right { display: flex; align-items: center; gap: 14px; }

.viewswitch {
  display: flex; gap: 2px; padding: 3px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 11px;
}
.vs-btn {
  width: 34px; height: 30px; display: flex; align-items: center; justify-content: center;
  color: var(--text-2); background: transparent; border: none; border-radius: 8px; cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.vs-btn svg { width: 18px; height: 18px; }
.vs-btn:hover { color: var(--text); }
.vs-btn.is-active { color: #1a0d04; background: var(--accent-grad); box-shadow: 0 2px 8px rgba(255,100,25,0.35); }

.count { font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.signout {
  width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  color: var(--text-2); background: transparent; border: 1px solid var(--line); border-radius: 10px; cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.signout svg { width: 17px; height: 17px; }
.signout:hover { color: var(--accent-soft); border-color: var(--line-strong); }

/* ---------- Add ---------- */
.add { display: flex; gap: 10px; margin: 40px 0 26px; }
.add-input {
  flex: 1; height: 56px; padding: 0 20px;
  font-size: 17px; font-family: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); box-shadow: var(--shadow);
  transition: border-color 0.18s, box-shadow 0.18s; outline: none;
}
.add-input::placeholder { color: var(--text-3); }
.add-input:focus {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line-strong));
  box-shadow: var(--shadow), 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent);
}
.add-btn { height: 56px; }

/* ---------- Orbit / 3D ---------- */
.orbit {
  position: relative;
  height: 460px; margin: 0 0 20px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  background:
    radial-gradient(80% 90% at 50% 10%, rgba(255,122,26,0.10), transparent 60%),
    linear-gradient(180deg, #17120e 0%, #0b0908 100%);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,180,120,0.06);
}
#orbit-canvas { width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
#orbit-canvas:active { cursor: grabbing; }
.orbit-hint {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%);
  font-size: 12.5px; color: var(--text-3); pointer-events: none;
  padding: 6px 14px; border-radius: 999px;
  background: color-mix(in srgb, #000 40%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}

/* ---------- Toolbar ---------- */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.filters { display: flex; gap: 6px; }
.chip {
  height: 34px; padding: 0 15px; font-size: 14px; font-weight: 450; font-family: inherit;
  color: var(--text-2); background: transparent; border: 1px solid transparent; border-radius: 999px;
  cursor: pointer; transition: background 0.15s, color 0.15s, border-color 0.15s; white-space: nowrap;
}
.chip:hover { color: var(--text); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.chip.is-active { color: var(--text); background: var(--surface); border-color: var(--line-strong); box-shadow: var(--shadow); }
.search input {
  height: 34px; padding: 0 14px; font-size: 14px; font-family: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px; outline: none;
  width: 180px; transition: border-color 0.18s, box-shadow 0.18s, width 0.2s;
}
.search input:focus {
  width: 220px; border-color: color-mix(in srgb, var(--accent) 55%, var(--line-strong));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 14%, transparent);
}

.tagbar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 26px; }
.tagbar:empty { display: none; }
.tag-toggle {
  height: 28px; padding: 0 12px; font-size: 13px; font-family: inherit;
  color: var(--text-2); background: transparent; border: 1px solid var(--line); border-radius: 999px;
  cursor: pointer; transition: all 0.15s;
}
.tag-toggle:hover { color: var(--text); border-color: var(--line-strong); }
.tag-toggle.is-active { color: #1a0d04; background: var(--accent-grad); border-color: transparent; }

/* ---------- Grid ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; padding-bottom: 80px; }
.card {
  position: relative; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow);
  transition: transform 0.2s cubic-bezier(0.2,0.7,0.2,1), box-shadow 0.2s, opacity 0.3s;
  animation: rise 0.4s cubic-bezier(0.2,0.7,0.2,1) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); }
.card.is-read { opacity: 0.55; }
.card.is-read:hover { opacity: 1; }

.card-media { display: block; aspect-ratio: 16 / 9; background: var(--surface-2); cursor: pointer; overflow: hidden; position: relative; text-decoration: none; }
.card-media img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.4s cubic-bezier(0.2,0.7,0.2,1); }
.card:hover .card-media img { transform: scale(1.04); }
.card-media.is-placeholder { background: var(--accent-grad); display: flex; align-items: center; justify-content: center; }
.card-media.is-placeholder span { font-size: 30px; font-weight: 600; color: rgba(26,13,4,0.82); text-transform: uppercase; letter-spacing: 0.04em; }

.card-body { padding: 16px 16px 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card-site { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-3); }
.card-fav { color: var(--accent-soft); display: inline-flex; }
.card-fav svg { width: 12px; height: 12px; }
.card-title {
  margin: 0; font-size: 15.5px; font-weight: 600; line-height: 1.35; letter-spacing: -0.015em; cursor: pointer;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-title:hover { color: var(--accent-soft); }
.card-desc {
  margin: 0; font-size: 13px; line-height: 1.5; color: var(--text-2);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 2px; }
.card-tag { font-size: 11.5px; color: var(--text-2); padding: 2px 8px; border-radius: 6px; background: color-mix(in srgb, var(--accent) 10%, transparent); }

.card-actions { display: flex; align-items: center; gap: 4px; padding: 8px 10px; border-top: 1px solid var(--line); margin-top: auto; }
.act {
  height: 32px; min-width: 32px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 0 10px; font-size: 13px; font-family: inherit; color: var(--text-2);
  background: transparent; border: none; border-radius: 8px; cursor: pointer; transition: background 0.15s, color 0.15s;
}
.act:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--text); }
.act.is-on { color: var(--accent-soft); }
.act-fav.is-on { color: var(--accent-soft); }
.act-del:hover { color: #ff5a48; background: color-mix(in srgb, #ff5a48 14%, transparent); }
.act svg { width: 16px; height: 16px; }
.spacer { flex: 1; }

/* ---------- Empty ---------- */
.empty { text-align: center; padding: 80px 20px 120px; }
.empty-mark { width: 58px; height: 58px; margin: 0 auto 20px; border-radius: 17px; background: var(--accent-grad); box-shadow: var(--glow); display: flex; align-items: center; justify-content: center; }
.empty-mark .logo-glyph { background: rgba(0,0,0,0.82); }
.empty-title { margin: 0 0 6px; font-size: 19px; font-weight: 600; }
.empty-sub { margin: 0; font-size: 15px; color: var(--text-2); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px);
  padding: 12px 20px; font-size: 14px; font-weight: 450; color: var(--text);
  background: color-mix(in srgb, var(--surface-hi) 90%, transparent);
  backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: var(--shadow-hover);
  opacity: 0; z-index: 50; transition: opacity 0.25s, transform 0.25s cubic-bezier(0.2,0.7,0.2,1);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 560px) {
  .add { flex-direction: column; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .search input, .search input:focus { width: 100%; }
  .orbit { height: 380px; }
}
