:root {
  --bg: #fbfaf8;
  --surface: #ffffff;
  --surface-2: #f2f0ec;
  --line: #e4e0d9;
  --text: #1b1a18;
  --muted: #74706a;
  --accent: #b4543a;
  --accent-soft: #f6e6e0;
  --shadow: 0 1px 2px rgba(27, 26, 24, 0.06), 0 8px 24px rgba(27, 26, 24, 0.06);
  --radius: 14px;
  --gutter: 16px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f0f12;
    --surface: #18181d;
    --surface-2: #212128;
    --line: #2d2d36;
    --text: #edecea;
    --muted: #9a968f;
    --accent: #e0805f;
    --accent-soft: #33221c;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0f0f12;
  --surface: #18181d;
  --surface-2: #212128;
  --line: #2d2d36;
  --text: #edecea;
  --muted: #9a968f;
  --accent: #e0805f;
  --accent-soft: #33221c;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.3);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Pretendard", "Apple SD Gothic Neo",
    "Malgun Gothic", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

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

/* ---------- 로그인 ---------- */

.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: var(--gutter);
}

.login-box {
  width: 100%;
  max-width: 320px;
  display: grid;
  gap: 12px;
  text-align: center;
}

.login-mark {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--accent);
}

.login-sub {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 14px;
}

.login-error {
  margin: 0;
  min-height: 20px;
  font-size: 13px;
  color: #d9534f;
}

/* ---------- 상단 ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  padding: env(safe-area-inset-top) var(--gutter) 0;
}

.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
}

.brand {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--accent);
}

.search-wrap {
  padding: 10px 0 8px;
}

input[type="search"],
input[type="password"],
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  outline: none;
}

input:focus-visible,
textarea:focus-visible {
  border-color: var(--accent);
}

.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 10px;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  flex: 0 0 auto;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13.5px;
  cursor: pointer;
  white-space: nowrap;
}

.tab[aria-selected="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

/* ---------- 카드 ---------- */

main {
  padding: 14px var(--gutter) 48px;
}

.grid {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}

@media (min-width: 560px) {
  .grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 900px) {
  .grid {
    grid-template-columns: repeat(3, 1fr);
    max-width: 1100px;
    margin: 0 auto;
  }
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.card.is-read {
  opacity: 0.62;
}

.card-img {
  display: block;
  width: 100%;
  max-height: 260px;
  object-fit: cover;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}

.card-body {
  padding: 12px 14px 10px;
  display: grid;
  gap: 6px;
}

.card-title {
  margin: 0;
  font-size: 15.5px;
  font-weight: 650;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.card-title a {
  color: inherit;
  text-decoration: none;
}

.card-title a:hover {
  text-decoration: underline;
}

.card-summary {
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
  overflow-wrap: anywhere;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.tag {
  font-size: 11.5px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
}

.card-foot {
  margin-top: auto;
  padding: 8px 10px 10px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}

.card-foot .spacer {
  flex: 1;
}

.card-foot select {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 3px 6px;
  font-size: 12px;
}

.icon-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1;
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

/* ---------- 버튼·기타 ---------- */

.btn-primary {
  padding: 10px 16px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.btn-ghost {
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.btn-ghost:hover {
  background: var(--surface-2);
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 48px 0;
  font-size: 14px;
}

.more-wrap {
  display: flex;
  justify-content: center;
  padding-top: 18px;
}

.sheet {
  border: none;
  border-radius: 16px;
  padding: 18px;
  width: min(420px, calc(100vw - 32px));
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.sheet::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

.sheet h2 {
  margin: 0 0 12px;
  font-size: 17px;
}

.sheet label {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--muted);
}

.sheet-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  padding: 11px 16px;
  border-radius: 12px;
  background: var(--text);
  color: var(--bg);
  font-size: 13.5px;
  box-shadow: var(--shadow);
  z-index: 50;
}
