:root {
  color-scheme: light;
  --brand: #6f2838;
  --brand-soft: #eadde0;
  --accent: #1f6c73;
  --accent-soft: #dcebed;
  --ink: #202326;
  --muted: #687078;
  --line: #d8d6d1;
  --paper: #fffdf9;
  --canvas: #eef1f3;
  --danger: #a23b3b;
  --shadow: 0 10px 28px rgba(28, 33, 38, 0.08);
  font-family: Pretendard, "Noto Sans KR", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; color: var(--ink); background: var(--canvas); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 66px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 249, 0.96);
}

.brand-link { display: flex; align-items: center; gap: 11px; color: inherit; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 7px; color: white; background: var(--brand); font-weight: 800; }
.brand-copy strong { display: block; font-size: 18px; }
.brand-copy span { display: block; margin-top: 1px; color: var(--muted); font-size: 12px; }
.header-actions { display: flex; align-items: center; gap: 8px; }

.icon-button, .button, .text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
}
.icon-button { width: 38px; padding: 0; }
.button { padding: 0 15px; font-weight: 700; }
.button.primary { border-color: var(--brand); background: var(--brand); color: white; }
.button.secondary { border-color: #94b9bd; color: #185b61; background: #f7ffff; }
.button:disabled { cursor: default; opacity: 0.48; }
.text-button { min-height: 32px; padding: 0 10px; border-color: transparent; color: var(--muted); background: transparent; }
.icon-button:hover, .button:hover { border-color: var(--brand); }

.page { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 38px 0 64px; }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.page-heading h1 { margin: 0; font-size: 28px; letter-spacing: 0; }
.page-heading p { margin: 7px 0 0; color: var(--muted); line-height: 1.55; }

.summary-strip { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 18px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); }
.summary-item { min-height: 82px; padding: 17px 20px; border-right: 1px solid var(--line); }
.summary-item:last-child { border-right: 0; }
.summary-item span { display: block; color: var(--muted); font-size: 12px; }
.summary-item strong { display: block; margin-top: 7px; font-size: 21px; }

.project-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 22px 0 14px; }
.project-toolbar h2 { margin: 0; font-size: 17px; }
.search-field { position: relative; width: min(320px, 100%); }
.search-field svg { position: absolute; left: 11px; top: 50%; width: 17px; transform: translateY(-50%); color: var(--muted); }
.search-field input { width: 100%; height: 40px; padding: 0 12px 0 38px; border: 1px solid var(--line); border-radius: 7px; background: var(--paper); }

.project-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.project-card { position: relative; display: grid; grid-template-rows: 150px auto; min-width: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; color: inherit; text-decoration: none; background: var(--paper); box-shadow: 0 1px 0 rgba(0,0,0,0.02); cursor: pointer; }
.project-card:hover { border-color: #b0aba2; box-shadow: var(--shadow); }
.project-card:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 35%, transparent); outline-offset: 3px; }
.project-cover { position: relative; display: grid; place-items: center; overflow: hidden; background: #ded9d1; }
.project-cover img { width: 100%; height: 100%; object-fit: cover; }
.project-cover-placeholder { display: grid; place-items: center; width: 58px; height: 72px; border: 1px solid rgba(32,35,38,0.25); color: rgba(32,35,38,0.65); font-weight: 800; background: rgba(255,255,255,0.28); }
.project-card-body { padding: 17px 17px 15px; }
.project-meta { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-bottom: 9px; }
.project-time { color: var(--muted); font-size: 11px; white-space: nowrap; }
.project-title { margin: 0; font-size: 19px; line-height: 1.35; }
.project-summary { display: -webkit-box; min-height: 43px; margin: 8px 0 17px; overflow: hidden; color: var(--muted); font-size: 13px; line-height: 1.6; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.project-card-footer { display: flex; align-items: center; justify-content: space-between; border-top: 1px solid #ece9e3; padding-top: 12px; }
.sync-label { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 11px; }
.sync-label svg { width: 14px; }

.empty-state, .loading-state, .error-state { padding: 46px 22px; border: 1px dashed #bbb7ae; border-radius: 8px; text-align: center; background: rgba(255,255,255,0.55); }
.empty-state svg, .loading-state svg, .error-state svg { width: 30px; height: 30px; color: var(--muted); }
.empty-state h2, .error-state h2 { margin: 13px 0 6px; font-size: 18px; }
.empty-state p, .error-state p { margin: 0 0 18px; color: var(--muted); }

.login-shell { display: grid; min-height: calc(100vh - 66px); place-items: center; padding: 30px; }
.login-panel { width: min(430px, 100%); padding: 32px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); box-shadow: var(--shadow); }
.login-panel .brand-mark { width: 42px; height: 42px; }
.login-panel h1 { margin: 22px 0 10px; font-size: 26px; }
.login-panel p { margin: 0 0 24px; color: var(--muted); line-height: 1.65; }
.login-panel .button { width: 100%; }

dialog { width: min(530px, calc(100% - 32px)); padding: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--ink); box-shadow: 0 24px 80px rgba(20,24,28,0.22); }
dialog::backdrop { background: rgba(22,25,27,0.46); }
.dialog-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.dialog-header h2 { margin: 0; font-size: 19px; }
.dialog-body { display: grid; gap: 18px; padding: 22px; }
.field { display: grid; gap: 7px; }
.field span { font-size: 12px; font-weight: 800; }
.field input, .field textarea, .field select { width: 100%; border: 1px solid var(--line); border-radius: 7px; padding: 11px 12px; background: white; color: var(--ink); }
.field textarea { min-height: 84px; resize: vertical; line-height: 1.55; }
.field small { color: var(--muted); line-height: 1.45; }
.template-options { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.template-option { position: relative; }
.template-option input { position: absolute; opacity: 0; pointer-events: none; }
.template-option span { display: block; min-height: 92px; padding: 14px; border: 1px solid var(--line); border-radius: 7px; background: white; }
.template-option strong { display: block; margin-bottom: 5px; }
.template-option small { color: var(--muted); line-height: 1.45; }
.template-option input:checked + span { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); background: #fffafb; }
.dialog-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 22px; border-top: 1px solid var(--line); }
.form-error { margin: 0; color: var(--danger); font-size: 12px; }

.workbench-header { min-height: 54px; }
.workbench-title { display: flex; align-items: center; gap: 11px; min-width: 0; }
.workbench-title h1 { margin: 0; overflow: hidden; font-size: 17px; text-overflow: ellipsis; white-space: nowrap; }
.workbench-status { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.workbench-status svg { width: 14px; }
.workbench-frame { display: block; width: 100%; height: calc(100vh - 55px); border: 0; background: white; }

@media (max-width: 860px) {
  .project-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .summary-strip { grid-template-columns: 1fr; }
  .summary-item { min-height: 0; border-right: 0; border-bottom: 1px solid var(--line); }
  .summary-item:last-child { border-bottom: 0; }
}

@media (max-width: 620px) {
  .app-header { padding: 0 16px; }
  .brand-copy span { display: none; }
  .page { width: min(100% - 24px, 1180px); padding-top: 24px; }
  .page-heading { align-items: stretch; flex-direction: column; }
  .page-heading .button { width: 100%; }
  .project-toolbar { align-items: stretch; flex-direction: column; }
  .search-field { width: 100%; }
  .project-grid { grid-template-columns: 1fr; }
  .template-options { grid-template-columns: 1fr; }
  .workbench-status span { display: none; }
}
