:root {
  color-scheme: light;
  --bg: #f4f6f6;
  --surface: #ffffff;
  --surface-muted: #f8faf9;
  --ink: #172024;
  --muted: #647176;
  --subtle: #8a969a;
  --line: #dce3e3;
  --line-strong: #c5d0d0;
  --brand: #236a73;
  --brand-strong: #164d55;
  --brand-soft: #e8f2f2;
  --accent: #b76335;
  --accent-soft: #fff2ea;
  --success: #27705d;
  --shadow-sm: 0 1px 2px rgba(23, 32, 36, 0.06);
  --shadow-md: 0 16px 36px rgba(23, 32, 36, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(35, 106, 115, 0.12) 0, rgba(35, 106, 115, 0) 300px),
    radial-gradient(circle at top left, rgba(183, 99, 53, 0.08), transparent 280px),
    var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "Noto Sans KR", system-ui, sans-serif;
}

button,
input,
select {
  font: inherit;
}

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

.app-shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 22px 0 48px;
}

.topbar,
.controls,
.summary-band,
.feed-header {
  width: 100%;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  min-height: 132px;
  padding: 22px 0 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--brand);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin-bottom: 0;
  color: #101719;
  font-size: 3rem;
  line-height: 1.08;
}

.sync-block {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border: 1px solid rgba(197, 208, 208, 0.75);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
  box-shadow: var(--shadow-sm);
}

.sync-block p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.92rem;
  white-space: nowrap;
}

button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  font-weight: 800;
  padding: 0 15px;
  transition:
    background-color 150ms ease,
    border-color 150ms ease,
    box-shadow 150ms ease,
    color 150ms ease,
    transform 150ms ease;
}

button:hover:not(:disabled) {
  background: var(--brand-strong);
  box-shadow: 0 8px 18px rgba(22, 77, 85, 0.16);
  transform: translateY(-1px);
}

button:active:not(:disabled) {
  transform: translateY(0);
}

button span {
  display: inline-block;
  margin-right: 6px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
}

input::placeholder {
  color: var(--subtle);
}

select {
  cursor: pointer;
}

input:focus,
select:focus,
button:focus-visible,
.rich-editor:focus {
  outline: 3px solid rgba(183, 99, 53, 0.26);
  outline-offset: 2px;
}

.controls {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 190px 170px auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
  border: 1px solid rgba(197, 208, 208, 0.84);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(14px);
}

.toggle {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
  color: var(--ink);
}

.toggle input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--brand);
}

.summary-band {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 16px;
}

.summary-band article {
  min-height: 86px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.summary-band span {
  display: block;
  color: var(--brand-strong);
  font-size: 1.72rem;
  font-weight: 900;
  line-height: 1.05;
}

.summary-band p {
  margin: 8px 0 0;
  color: var(--muted);
}

.scrapbook {
  margin-top: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.scrapbook-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
}

.scrapbook h2,
.feed-header h2 {
  margin-bottom: 4px;
  font-size: 1.18rem;
  line-height: 1.25;
}

.scrapbook p,
.feed-header p {
  margin-bottom: 0;
  color: var(--muted);
}

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

.export-actions button,
.format-toolbar button,
.scrap-row button,
.scrap-button,
#closePreviewButton {
  min-height: 36px;
  background: #fff;
  color: var(--brand-strong);
  border-color: var(--line-strong);
  padding: 0 11px;
}

.export-actions button:hover:not(:disabled),
.format-toolbar button:hover:not(:disabled),
.scrap-row button:hover:not(:disabled),
.scrap-button:hover:not(:disabled),
#closePreviewButton:hover:not(:disabled) {
  background: var(--brand-soft);
  border-color: rgba(35, 106, 115, 0.4);
  color: var(--brand-strong);
}

.print-settings {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
  padding: 10px 12px;
}

.print-settings summary {
  cursor: pointer;
  color: var(--brand-strong);
  font-weight: 900;
}

.print-settings-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.scrap-list {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.scrap-empty,
.empty-state {
  padding: 22px 18px;
  border: 1px dashed #b7c4c4;
  border-radius: 8px;
  background: var(--surface-muted);
  color: var(--muted);
  text-align: center;
}

.scrap-group {
  display: grid;
  gap: 8px;
}

.scrap-group h3 {
  margin-bottom: 0;
  color: var(--brand-strong);
  font-size: 0.9rem;
}

.scrap-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.scrap-row label {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  color: var(--ink);
  font-weight: 800;
}

.scrap-row input {
  width: 18px;
  min-height: 18px;
  flex: 0 0 auto;
  accent-color: var(--brand);
}

.scrap-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scrap-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  justify-content: flex-end;
}

.scrap-row button {
  min-height: 32px;
  color: var(--muted);
  font-size: 0.82rem;
}

.preview-panel {
  display: grid;
  gap: 14px;
  margin-top: 18px;
  padding: 16px;
  border: 1px solid rgba(35, 106, 115, 0.3);
  border-radius: 8px;
  background: linear-gradient(180deg, #fbfefe, #ffffff);
}

.preview-panel[hidden] {
  display: none;
}

.preview-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.preview-toolbar h3 {
  margin-bottom: 0;
  font-size: 1.14rem;
}

.format-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.format-toolbar button,
.color-tool {
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--brand-strong);
  font-size: 0.86rem;
  font-weight: 900;
  padding: 0 10px;
}

.color-tool {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.color-tool input {
  width: 28px;
  min-height: 28px;
  border: 0;
  padding: 0;
}

.rich-editor {
  width: 100%;
  min-height: 260px;
  max-height: 560px;
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
  color: #111111;
  font-size: 1rem;
  line-height: 1.75;
}

.rich-editor p {
  margin: 0 0 1.15rem;
}

.rich-editor h1,
.rich-editor h2,
.rich-editor h3 {
  margin: 1.2rem 0 0.6rem;
}

.rich-editor hr {
  margin: 1.35rem 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.export-article p {
  margin-bottom: 1rem;
}

.preview-actions {
  display: flex;
  justify-content: flex-end;
}

.feed-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-top: 28px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.feed-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.feed-item {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 16px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition:
    border-color 150ms ease,
    box-shadow 150ms ease,
    transform 150ms ease;
}

.feed-item:hover {
  border-color: rgba(35, 106, 115, 0.34);
  box-shadow: 0 12px 26px rgba(23, 32, 36, 0.08);
  transform: translateY(-1px);
}

.date-pill {
  height: 72px;
  display: grid;
  place-items: center;
  align-content: center;
  border-radius: 8px;
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.date-pill strong {
  font-size: 1.58rem;
  line-height: 1;
}

.date-pill span {
  font-size: 0.74rem;
  font-weight: 900;
}

.item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 0.84rem;
}

.item-meta span {
  border-radius: 999px;
  background: var(--accent-soft);
  color: #864b27;
  font-weight: 900;
  padding: 4px 9px;
}

.feed-content h3 {
  margin: 8px 0 6px;
  font-size: 1.16rem;
  line-height: 1.38;
}

.feed-content a {
  color: var(--ink);
  text-decoration: none;
}

.feed-content a:hover {
  color: var(--brand-strong);
  text-decoration: underline;
  text-decoration-color: rgba(35, 106, 115, 0.45);
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

.feed-content p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.62;
}

.scrap-button {
  width: fit-content;
  margin-top: 12px;
}

.scrap-button:disabled {
  background: #edf6f2;
  color: var(--success);
  border-color: rgba(39, 112, 93, 0.24);
  opacity: 1;
}

@media (max-width: 900px) {
  h1 {
    font-size: 2.35rem;
  }

  .topbar,
  .feed-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .sync-block {
    width: 100%;
    justify-content: space-between;
  }

  .controls {
    grid-template-columns: 1fr 1fr;
  }

  .print-settings-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .scrap-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .scrap-row-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 620px) {
  .app-shell {
    width: min(100% - 22px, 1180px);
    padding-top: 12px;
  }

  h1 {
    font-size: 2rem;
  }

  .topbar {
    min-height: auto;
  }

  .controls,
  .summary-band,
  .print-settings-grid {
    grid-template-columns: 1fr;
  }

  .controls {
    position: static;
  }

  .scrapbook {
    padding: 14px;
  }

  .scrapbook-head,
  .export-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .export-actions button,
  .scrap-row-actions button,
  .format-toolbar button,
  .color-tool {
    width: 100%;
    justify-content: center;
  }

  .scrap-row-actions,
  .format-toolbar,
  .preview-toolbar,
  .preview-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .rich-editor {
    min-height: 220px;
    max-height: 60vh;
    font-size: 0.98rem;
  }

  .feed-item {
    grid-template-columns: 58px minmax(0, 1fr);
    gap: 12px;
    padding: 12px;
  }

  .date-pill {
    width: 58px;
    height: 58px;
  }

  .date-pill strong {
    font-size: 1.24rem;
  }
}
