:root {
  --ink: #20221d;
  --paper: #f5f1e8;
  --paper-deep: #e8e0d1;
  --green: #3f5b45;
  --green-dark: #263d2c;
  --orange: #d7693d;
  --line: rgba(32, 34, 29, 0.18);
  --muted: #77786f;
  --white: #fffdf8;
  --serif: Georgia, 'Times New Roman', serif;
  --sans: 'Noto Sans KR', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--sans);
  line-height: 1.55;
}

button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
img { display: block; max-width: 100%; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.site-header {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 76px;
  padding: 12px clamp(20px, 5vw, 72px);
  border-bottom: 1px solid var(--line);
  background: rgba(245, 241, 232, 0.93);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-family: var(--serif);
  font-size: 1.25rem;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 76px;
  height: 76px;
  place-items: center;
  border-radius: 50%;
  color: var(--paper);
  background: var(--green);
  font-family: var(--serif);
  font-size: 1.2rem;
  letter-spacing: 0.05em;
}

.brand-mark-small { width: 44px; height: 44px; font-size: 0.75rem; }

.profile { display: flex; align-items: center; gap: 12px; font-size: 0.86rem; }
.avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.menu-button { display: grid; width: 42px; height: 42px; padding: 10px; place-content: center; gap: 4px; border: 1px solid var(--line); border-radius: 50%; cursor: pointer; background: transparent; }
.menu-button[hidden] { display: none; }
.menu-button span { display: block; width: 18px; height: 2px; border-radius: 2px; background: var(--ink); }
.menu-button:hover { background: var(--paper-deep); }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  text-decoration: none;
  transition: transform 150ms ease, background 150ms ease, opacity 150ms ease;
}

.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: wait; opacity: 0.55; transform: none; }
.button-primary { color: var(--white); background: var(--green-dark); }
.button-primary:hover { background: var(--green); }
.button-secondary { border-color: var(--ink); background: transparent; }
.button-quiet { min-height: 38px; padding: 7px 14px; border-color: var(--line); background: transparent; }
.button-danger { border-color: #a43928; color: #8d3022; background: transparent; }
.google-login { width: 100%; gap: 12px; }
.google-login span { display: grid; width: 24px; height: 24px; place-items: center; border-radius: 50%; color: var(--green-dark); background: white; }

.page-shell { width: min(1240px, calc(100% - 40px)); margin: 0 auto; padding-bottom: 100px; }

.hero { padding: clamp(70px, 10vw, 140px) 0 clamp(60px, 9vw, 120px); }
.hero h1 {
  margin: 10px 0 24px;
  font-family: var(--serif);
  font-size: clamp(3rem, 7vw, 6.8rem);
  font-weight: 400;
  letter-spacing: -0.035em;
  line-height: 0.98;
}
.hero h1 span { display: block; white-space: nowrap; }
.hero > p:last-child { max-width: 630px; margin: 0; color: var(--muted); font-size: 1.05rem; }
.eyebrow, .section-number { margin: 0; color: var(--orange); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.16em; }

.import-panel, .preview-panel {
  padding: clamp(24px, 4vw, 52px);
  border-radius: 28px;
  background: var(--green);
  color: var(--white);
}

.import-panel { display: grid; grid-template-columns: minmax(180px, 0.7fr) 2fr; gap: 30px 54px; align-items: center; }
.import-panel h2, .preview-panel h2, .library h2 { margin: 4px 0 0; font-family: var(--serif); font-size: clamp(2rem, 4vw, 3.4rem); font-weight: 400; }
.import-form { display: flex; gap: 10px; padding: 8px; border-radius: 999px; background: var(--white); }
.import-form input { flex: 1; min-width: 0; padding: 10px 18px; border: 0; outline: 0; color: var(--ink); background: transparent; }
.status { grid-column: 2; padding: 12px 18px; border-radius: 12px; background: rgba(255, 255, 255, 0.1); }
.status.success { color: #d8efc9; }
.status.error { color: #ffd0c4; }

.preview-panel { margin-top: 28px; color: var(--ink); background: var(--white); border: 1px solid var(--line); }
.section-heading, .editor-section-heading, .editor-group-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.preview-layout { display: grid; grid-template-columns: minmax(240px, 0.8fr) 1.2fr; gap: 38px; margin-top: 34px; }
.preview-image, .detail-image, .recipe-card-image {
  position: relative;
  display: grid;
  overflow: hidden;
  place-items: center;
  color: rgba(255, 255, 255, 0.7);
  background: var(--green-dark);
}
.preview-image { min-height: 330px; border-radius: 20px; }
.preview-image img, .detail-image img, .recipe-card-image img { width: 100%; height: 100%; object-fit: cover; }
.preview-image .platform-label { position: absolute; bottom: 16px; left: 16px; }
.platform-label { display: inline-flex; padding: 5px 10px; border-radius: 999px; color: var(--white); background: var(--orange); font-size: 0.67rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }

.editor-fields { display: grid; gap: 18px; }
.editor-fields.two-column { grid-template-columns: 1fr 1fr; margin-top: 28px; }
.editor-fields label { display: grid; gap: 7px; color: var(--muted); font-size: 0.78rem; font-weight: 700; }
.editor-fields input, .editor-fields textarea, .editor-group input, .ingredient-row input, .step-row textarea, .step-row input {
  width: 100%;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  color: var(--ink);
  background: #fff;
}
.editor-fields input:focus, .editor-fields textarea:focus, .editor-group input:focus, .ingredient-row input:focus, .step-row textarea:focus, .step-row input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(63, 91, 69, 0.12); }
.editor-fields #recipe-title { font-family: var(--serif); font-size: 2rem; }
.editor-section { margin-top: 36px; padding-top: 30px; border-top: 1px solid var(--line); }
.editor-section h3 { margin: 0; font-family: var(--serif); font-size: 1.7rem; font-weight: 400; }
.editor-group { margin: 18px 0 0; padding: 18px; border: 1px solid var(--line); border-radius: 14px; }
.editor-group-heading > input { max-width: 300px; font-weight: 700; }
.ingredient-list { display: grid; gap: 8px; margin: 14px 0; }
.ingredient-row { display: grid; grid-template-columns: 1fr 0.75fr 38px; gap: 8px; }
.text-button, .icon-button { border: 0; cursor: pointer; color: var(--green); background: transparent; font-weight: 700; }
.text-button.danger { color: #9a3c2c; }
.icon-button { font-size: 1.25rem; }
.step-row { display: grid; grid-template-columns: 34px 1fr 90px 34px; gap: 10px; align-items: start; margin-top: 12px; }
.step-row > span { display: grid; width: 32px; height: 32px; place-items: center; border-radius: 50%; color: var(--white); background: var(--green); font-size: 0.75rem; }
.form-actions { display: flex; justify-content: flex-end; margin-top: 30px; }

.library { padding-top: clamp(70px, 10vw, 120px); }
.count-label { color: var(--muted); font-size: 0.72rem; letter-spacing: 0.12em; }
.recipe-search { display: flex; max-width: 660px; gap: 10px; margin-top: 30px; padding: 8px 14px 8px 20px; border: 1px solid var(--line); border-radius: 999px; background: var(--white); }
.recipe-search:focus-within { border-color: var(--green); box-shadow: 0 0 0 3px rgba(63, 91, 69, 0.12); }
.recipe-search input { flex: 1; min-width: 0; padding: 6px 0; border: 0; outline: 0; color: var(--ink); background: transparent; }
.tag-filter { margin-top: 30px; padding: 18px 20px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255, 253, 248, 0.65); }
.tag-filter-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; font-size: 0.82rem; font-weight: 700; }
.tag-filter-heading small { margin-left: 8px; color: var(--muted); font-weight: 400; }
.tag-filter-actions { display: flex; align-items: center; gap: 12px; }
.tag-filter-options { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 13px; }
.tag-filter-button { padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px; cursor: pointer; color: var(--green); background: var(--white); font-size: 0.78rem; }
.tag-filter-button[aria-pressed="true"] { border-color: var(--green); color: var(--white); background: var(--green); }
.recipe-results { min-height: 430px; }
.recipe-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; margin-top: 38px; }
.recipe-card { overflow: hidden; border: 1px solid var(--line); border-radius: 20px; background: var(--white); text-decoration: none; transition: transform 180ms ease, box-shadow 180ms ease; }
.recipe-card:hover { transform: translateY(-4px); box-shadow: 0 18px 50px rgba(38, 61, 44, 0.12); }
.recipe-card-image { aspect-ratio: 4 / 3; }
.recipe-card-body { padding: 22px; }
.recipe-card-body h3 { margin: 13px 0 7px; font-family: var(--serif); font-size: 1.65rem; font-weight: 400; line-height: 1.12; }
.recipe-card-body p { margin: 0; color: var(--muted); font-size: 0.85rem; }
.recipe-card-body .recipe-card-match { margin-top: 12px; color: var(--orange); font-weight: 700; }
.recipe-card-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.recipe-card-tags .tag { margin: 0; }
.empty-state { padding: 50px; text-align: center; color: var(--muted); }

.drawer-open { overflow: hidden; }
.drawer-backdrop { position: fixed; z-index: 39; inset: 0; border: 0; cursor: default; background: rgba(32, 34, 29, 0.42); }
.access-drawer { position: fixed; z-index: 40; top: 0; right: 0; width: min(440px, 100%); height: 100dvh; overflow-y: auto; padding: 34px; border-left: 1px solid var(--line); background: var(--white); box-shadow: -20px 0 70px rgba(32, 34, 29, 0.2); }
.drawer-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.drawer-heading h2 { margin: 4px 0 0; font-family: var(--serif); font-size: 2.4rem; font-weight: 400; line-height: 1.05; }
.drawer-close { display: grid; width: 42px; height: 42px; flex: 0 0 auto; padding: 0; place-items: center; border: 1px solid var(--line); border-radius: 50%; cursor: pointer; color: var(--ink); background: transparent; font-size: 1.8rem; line-height: 1; }
.drawer-close:hover { background: var(--paper); }
.drawer-account { display: grid; gap: 2px; margin-top: 34px; padding: 18px; border-radius: 14px; background: var(--paper); }
.drawer-account strong { font-family: var(--serif); font-size: 1.25rem; font-weight: 400; }
.drawer-account span { overflow-wrap: anywhere; color: var(--muted); font-size: 0.78rem; }
.drawer-actions { display: grid; gap: 10px; margin-top: 28px; }
.drawer-action { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 52px; padding: 12px 16px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; color: var(--ink); background: transparent; font-weight: 700; text-align: left; }
.drawer-action:hover { background: var(--paper); }
.drawer-action small { color: var(--orange); font-size: 0.68rem; }
.drawer-action.danger { color: #8d3022; }
.drawer-action[hidden] { display: none; }
.access-overlay-backdrop { position: fixed; z-index: 59; inset: 0; border: 0; cursor: default; background: rgba(32, 34, 29, 0.55); }
.access-overlay { position: fixed; z-index: 60; top: 50%; left: 50%; width: min(560px, calc(100% - 40px)); max-height: min(720px, calc(100dvh - 40px)); overflow-y: auto; padding: 34px; border: 1px solid var(--line); border-radius: 24px; background: var(--white); box-shadow: 0 28px 90px rgba(32, 34, 29, 0.28); transform: translate(-50%, -50%); }
.access-copy { margin: 14px 0 20px; color: var(--muted); }
.access-form { display: grid; gap: 10px; }
.access-form input { width: 100%; min-width: 0; padding: 12px 16px; border: 1px solid var(--line); border-radius: 12px; outline: none; }
.access-form input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(63, 91, 69, 0.12); }
.allowed-email-list { display: grid; gap: 8px; margin-top: 22px; }
.allowed-email-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 12px 16px; border-radius: 12px; background: var(--paper); }
.allowed-email-row small { color: var(--muted); }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 75% 20%, #e5b79e 0, transparent 28%), var(--paper); }
.login-card { width: min(440px, 100%); padding: clamp(34px, 7vw, 62px); border: 1px solid var(--line); border-radius: 30px; background: rgba(255, 253, 248, 0.88); box-shadow: 0 30px 100px rgba(38, 61, 44, 0.14); text-align: center; backdrop-filter: blur(10px); }
.login-card .brand-mark { margin: 0 auto 28px; }
.login-card h1 { margin: 8px 0 16px; font-family: var(--serif); font-size: 3rem; font-weight: 400; line-height: 1; }
.login-copy { margin: 0 0 32px; color: var(--muted); }
.fine-print { margin: 18px 0 0; color: var(--muted); font-size: 0.72rem; }

.detail-shell { width: min(1160px, calc(100% - 40px)); margin: 0 auto; padding: 50px 0 100px; }
.back-link { display: inline-block; margin-bottom: 28px; color: var(--muted); text-decoration: none; }
.recipe-detail { overflow: hidden; border: 1px solid var(--line); border-radius: 28px; background: var(--white); }
.detail-hero { display: grid; grid-template-columns: 1.05fr 0.95fr; min-height: 480px; }
.detail-image { min-height: 420px; }
.detail-intro { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; padding: clamp(34px, 6vw, 74px); }
.detail-intro h1 { margin: 18px 0; font-family: var(--serif); font-size: clamp(2.7rem, 5vw, 5rem); font-weight: 400; line-height: 0.98; }
.detail-intro > p { color: var(--muted); }
.servings { margin: 12px 0 28px; color: var(--ink) !important; font-size: 0.82rem; font-weight: 700; }
.detail-columns { display: grid; grid-template-columns: 0.8fr 1.2fr; gap: clamp(36px, 7vw, 90px); padding: clamp(38px, 7vw, 86px); border-top: 1px solid var(--line); }
.detail-columns h2 { margin: 5px 0 28px; font-family: var(--serif); font-size: 2.5rem; font-weight: 400; }
.ingredient-detail { margin-bottom: 28px; }
.ingredient-detail h3 { margin: 0 0 10px; font-size: 0.86rem; }
.ingredient-detail ul, .tips ul { margin: 0; padding: 0; list-style: none; }
.ingredient-detail li { display: flex; justify-content: space-between; gap: 20px; padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: 0.9rem; }
.ingredient-detail li strong { font-weight: 500; color: var(--muted); }
.method-list { display: grid; gap: 22px; margin: 0; padding: 0; list-style: none; }
.method-list li { display: grid; grid-template-columns: 46px 1fr; gap: 18px; align-items: start; }
.method-list li > strong { color: var(--orange); font-family: var(--serif); font-size: 1.6rem; font-weight: 400; }
.method-list a { display: grid; color: inherit; text-decoration: none; }
.method-list small { margin-top: 4px; color: var(--orange); }
.tips { margin-top: 42px; padding: 24px; border-radius: 16px; background: var(--paper); }
.tips h3 { margin-top: 0; font-family: var(--serif); font-size: 1.5rem; font-weight: 400; }
.tips li { margin-top: 8px; }
.detail-footer { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 24px clamp(38px, 7vw, 86px); border-top: 1px solid var(--line); }
.detail-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.recipe-edit-panel { color: var(--ink); background: var(--white); }
.tag { margin-right: 12px; color: var(--green); font-size: 0.78rem; }
.scroll-to-top { position: fixed; z-index: 30; right: 24px; bottom: 24px; display: grid; width: 52px; height: 52px; padding: 0; place-items: center; border: 0; border-radius: 50%; cursor: pointer; color: var(--white); background: var(--green-dark); box-shadow: 0 12px 32px rgba(38, 61, 44, 0.28); font-size: 1.35rem; transition: transform 150ms ease, background 150ms ease; }
.scroll-to-top:hover { transform: translateY(-2px); background: var(--green); }
.scroll-to-top:focus-visible { outline: 3px solid var(--orange); outline-offset: 3px; }
.scroll-to-top[hidden] { display: none; }

.toast { position: fixed; z-index: 50; right: 24px; bottom: 24px; max-width: min(420px, calc(100% - 48px)); padding: 15px 20px; border-radius: 12px; color: var(--white); background: var(--green-dark); box-shadow: 0 14px 40px rgba(0, 0, 0, 0.2); }

@media (max-width: 860px) {
  .import-panel, .preview-layout, .detail-hero, .detail-columns { grid-template-columns: 1fr; }
  .status { grid-column: 1; }
  .recipe-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-intro { min-height: 380px; }
}

@media (max-width: 600px) {
  .site-header { min-height: 66px; gap: 8px; padding-inline: 12px; }
  .brand { min-width: 0; gap: 8px; font-size: clamp(0.86rem, 3.8vw, 1rem); }
  .brand-mark-small { width: 36px; height: 36px; flex: 0 0 auto; font-size: 0.62rem; }
  .brand > span:last-child { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .profile { min-width: 0; gap: 6px; }
  .profile #profile-name { display: block; overflow: hidden; max-width: clamp(44px, 15vw, 90px); font-size: 0.72rem; text-overflow: ellipsis; white-space: nowrap; }
  .profile .avatar { display: block; width: 28px; height: 28px; flex: 0 0 auto; }
  .profile .menu-button { width: 38px; height: 38px; flex: 0 0 auto; padding: 8px; }
  .profile .button-quiet { min-height: 36px; padding: 6px 9px; font-size: 0.72rem; }
  .page-shell, .detail-shell { width: min(100% - 24px, 1240px); }
  .hero { padding-top: 70px; }
  .hero h1 { font-size: clamp(1.45rem, 8.5vw, 4.5rem); }
  .import-panel, .preview-panel { padding: 24px 18px; border-radius: 20px; }
  .import-form { flex-direction: column; border-radius: 18px; }
  .import-form .button { width: 100%; }
  .recipe-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .recipe-card { border-radius: 14px; }
  .recipe-card-body { padding: 14px; }
  .recipe-card-body h3 { display: -webkit-box; overflow: hidden; margin: 10px 0 6px; font-size: 1.15rem; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
  .recipe-card-body > p:not(.recipe-card-match) { display: -webkit-box; overflow: hidden; font-size: 0.75rem; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
  .recipe-card-tags { gap: 4px; margin-top: 10px; }
  .recipe-card-tags .tag { font-size: 0.68rem; }
  .tag-filter-heading { align-items: flex-start; flex-direction: column; }
  .tag-filter-heading small { display: block; margin: 2px 0 0; }
  .recipe-results { min-height: 340px; }
  .recipe-search { border-radius: 18px; }
  .access-drawer { padding: 26px 20px; }
  .access-overlay { width: calc(100% - 24px); max-height: calc(100dvh - 24px); padding: 26px 20px; border-radius: 20px; }
  .editor-fields.two-column { grid-template-columns: 1fr; }
  .ingredient-row { grid-template-columns: 1fr 0.7fr 34px; }
  .step-row { grid-template-columns: 32px 1fr 30px; }
  .step-row [data-step-time] { grid-column: 2; }
  .detail-shell { padding-top: 28px; }
  .detail-hero { min-height: 0; }
  .detail-image { min-height: 300px; }
  .detail-columns { padding: 34px 22px; }
  .detail-footer { align-items: flex-start; flex-direction: column; padding: 24px 22px; }
  .scroll-to-top { right: 16px; bottom: 16px; width: 48px; height: 48px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
