:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-soft: #f9fafc;
  --line: #d9dee8;
  --line-strong: #b8c1cf;
  --text: #1d2433;
  --muted: #697386;
  --accent: #1f6feb;
  --accent-soft: #e8f0ff;
  --new: #e5484d;
  --shadow: 0 14px 35px rgba(34, 44, 62, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Noto Sans KR", system-ui, sans-serif;
}

button,
input {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(330px, 440px) minmax(0, 1fr);
  height: 100vh;
}

.feed-pane {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--panel);
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px 14px;
  border-bottom: 1px solid var(--line);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 20px;
  font-weight: 760;
  letter-spacing: 0;
}

.topbar p,
.muted {
  color: var(--muted);
  font-size: 13px;
}

.icon-button {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}

.icon-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-soft);
}

.toolbar-options {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.post-list {
  margin: 0;
  padding: 0;
  min-height: 0;
  flex: 1 1 auto;
  overflow: auto;
  list-style: none;
}

.post-item {
  border-bottom: 1px solid var(--line);
}

.post-button {
  width: 100%;
  padding: 14px 18px 13px 22px;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.post-button:hover,
.post-button.active {
  background: var(--accent-soft);
}

.post-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.category {
  flex: 0 0 auto;
  min-width: 42px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.post-title {
  overflow: hidden;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
  font-weight: 650;
}

.badge-new {
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--new);
  color: #fff;
  padding: 2px 6px;
  font-size: 11px;
  font-weight: 800;
}

.risk-badge {
  flex: 0 0 auto;
  margin-left: auto;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 800;
}

.risk-badge-low {
  background: #edf2ff;
  color: #4660a8;
}

.risk-badge-medium {
  background: #fff4cc;
  color: #8a6700;
}

.risk-badge-high {
  background: #ffe1d6;
  color: #b54708;
}

.risk-badge-critical {
  background: #ffe0e3;
  color: #c1121f;
}

.post-meta {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
}

.viewer-pane {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 26px;
}

#postViewer {
  max-width: 920px;
  margin: 0 auto;
}

.viewer-empty {
  display: grid;
  min-height: calc(100vh - 52px);
  place-items: center;
}

.empty-state {
  width: min(460px, 100%);
  padding: 28px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--panel);
  text-align: center;
}

.empty-state h2 {
  margin-bottom: 8px;
  font-size: 22px;
}

.empty-state p {
  color: var(--muted);
  line-height: 1.55;
}

.article {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.article-header {
  padding: 24px 26px 18px;
  border-bottom: 1px solid var(--line);
}

.article-header h2 {
  margin-top: 8px;
  font-size: 24px;
  line-height: 1.35;
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.risk-panel {
  margin-top: 18px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.risk-panel-low {
  background: #f5f8ff;
  border-color: #dbe5ff;
}

.risk-panel-medium {
  background: #fffaf0;
  border-color: #f1d39a;
}

.risk-panel-high {
  background: #fff4ed;
  border-color: #f2b089;
}

.risk-panel-critical {
  background: #fff1f3;
  border-color: #f2a3ac;
}

.risk-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 15px;
}

.risk-level-text {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.risk-summary {
  margin-top: 8px;
  color: var(--text);
  line-height: 1.5;
}

.risk-reasons {
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--muted);
}

.risk-reasons li + li {
  margin-top: 4px;
}

.risk-disclaimer {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.label-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.label-button {
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  padding: 7px 12px;
  cursor: pointer;
}

.label-button:disabled {
  opacity: 0.55;
  cursor: wait;
}

.label-button.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

.label-button-troll.active {
  border-color: #c1121f;
  background: #ffe0e3;
  color: #c1121f;
}

.label-button-normal.active {
  border-color: #18794e;
  background: #e7f7ee;
  color: #18794e;
}

.label-state,
.label-help {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.label-pill {
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
}

.label-pill-troll {
  background: #ffe0e3;
  color: #c1121f;
}

.label-pill-normal {
  background: #e7f7ee;
  color: #18794e;
}

.source-link {
  color: var(--accent);
  text-decoration: none;
}

.source-link:hover {
  text-decoration: underline;
}

.article-content {
  padding: 28px 26px;
  line-height: 1.72;
  word-break: break-word;
}

.article-content img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 12px 0;
  border-radius: 6px;
}

.article-content a {
  color: var(--accent);
}

.comments {
  border-top: 1px solid var(--line);
  background: var(--panel-soft);
}

.comments-header {
  padding: 18px 26px 10px;
  font-size: 17px;
  font-weight: 760;
}

.comment-list {
  margin: 0;
  padding: 0 26px 24px;
  list-style: none;
}

.comment {
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.comment.reply {
  padding-left: 18px;
}

.comment-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
}

.comment-author {
  color: var(--text);
  font-weight: 700;
}

.comment-text {
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.loading,
.error {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
}

.error {
  border-color: #f2b8b5;
  color: #b3261e;
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(260px, 46vh) minmax(0, 1fr);
    height: 100vh;
  }

  .feed-pane {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .viewer-pane {
    padding: 16px;
  }

  .toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .toolbar-options,
  .toolbar .muted,
  .post-meta {
    width: 100%;
  }

  .post-meta {
    flex-wrap: wrap;
  }

  .article-header,
  .article-content,
  .comments-header {
    padding-left: 18px;
    padding-right: 18px;
  }

  .comment-list {
    padding-left: 18px;
    padding-right: 18px;
  }
}
