:root {
  --ink: #151411;
  --muted: #726f67;
  --paper: #f4f1ea;
  --card: #fffdf8;
  --line: #ded9ce;
  --accent: #ef6042;
  --accent-dark: #ca432b;
  --green: #287858;
  --shadow: 0 16px 44px rgba(35, 30, 20, .08);
  font-family: Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--paper); }
button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }

.app-shell { width: min(100%, 760px); min-height: 100vh; margin: 0 auto; background: var(--paper); }
.topbar {
  position: relative; z-index: 20; height: 76px; padding: 12px 22px;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--paper);
  border-bottom: 1px solid rgba(222, 217, 206, .7);
}
.brand { display: flex; gap: 11px; align-items: center; border: 0; background: none; padding: 0; text-align: left; cursor: pointer; }
.brand-mark, .login-mark {
  display: grid; place-items: center; width: 42px; height: 42px; border-radius: 13px;
  background: var(--ink); color: #fff; font: 800 20px/1 Georgia, serif;
}
.brand strong { display: block; font: 800 16px/1.1 Georgia, serif; letter-spacing: -.01em; }
.brand small { display: block; color: var(--muted); margin-top: 4px; font-size: 10px; }
.avatar { width: 38px; height: 38px; border: 1px solid var(--line); background: var(--card); border-radius: 50%; font-weight: 800; cursor: pointer; }

main { padding: 28px 20px 112px; }
.eyebrow { margin: 0 0 8px; font-size: 11px; letter-spacing: .15em; font-weight: 800; color: var(--accent-dark); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 20px; }
.page-head h1, .message-detail h1, .sent-state h1, .empty-state h1 { margin: 0; font-family: Georgia, "Times New Roman", serif; letter-spacing: -.04em; }
.page-head h1 { font-size: clamp(30px, 8vw, 46px); }
.page-head h1 em { color: var(--accent); font-style: normal; }
.icon-button { border: 1px solid var(--line); background: var(--card); border-radius: 13px; width: 43px; height: 43px; font-size: 23px; cursor: pointer; }

.summary-strip { display: flex; align-items: center; gap: 11px; border: 1px solid var(--line); border-radius: 15px; padding: 13px 16px; background: rgba(255, 253, 248, .65); margin-bottom: 14px; }
.summary-strip p { margin: 0; }
.summary-strip strong, .summary-strip small { display: block; }
.summary-strip strong { font-size: 13px; }
.summary-strip small { color: var(--muted); font-size: 11px; margin-top: 3px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #30a46c; box-shadow: 0 0 0 5px rgba(48, 164, 108, .1); }

.mail-list { overflow: hidden; border-radius: 18px; border: 1px solid var(--line); background: var(--card); box-shadow: var(--shadow); }
.mail-card { width: 100%; display: grid; grid-template-columns: 7px 1fr 18px; gap: 12px; align-items: center; border: 0; border-bottom: 1px solid var(--line); background: transparent; padding: 18px 16px 18px 12px; text-align: left; cursor: pointer; }
.mail-card:last-child { border-bottom: 0; }
.mail-card:active { background: #f1ede4; }
.unread-mark { width: 7px; height: 7px; border-radius: 50%; }
.mail-card.unread .unread-mark { background: var(--accent); }
.mail-copy, .mail-meta strong, .mail-subject, .mail-snippet { min-width: 0; display: block; }
.mail-meta { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.mail-meta strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.mail-meta time { color: var(--muted); font-size: 10px; flex: none; }
.mail-subject { margin-top: 6px; font-weight: 750; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mail-snippet { color: var(--muted); margin-top: 5px; font-size: 12px; line-height: 1.45; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chevron { color: #aaa399; font-size: 26px; }

.bottom-nav { position: fixed; z-index: 30; bottom: 0; left: 50%; transform: translateX(-50%); width: min(100%, 760px); display: grid; grid-template-columns: 1fr 1fr; padding: 8px max(16px, env(safe-area-inset-left)) calc(8px + env(safe-area-inset-bottom)); background: rgba(20, 19, 16, .96); }
.bottom-nav button { border: 0; background: none; color: #8f8b82; padding: 7px; font-size: 10px; font-weight: 700; cursor: pointer; }
.bottom-nav span { display: block; font-size: 21px; line-height: 1; margin-bottom: 4px; }
.bottom-nav button.active { color: #fff; }

.detail-toolbar { display: grid; grid-template-columns: 40px 1fr 40px; align-items: center; margin: -12px 0 24px; font-size: 13px; font-weight: 700; text-align: center; }
.back-button, .more-button { border: 0; background: transparent; font-size: 32px; cursor: pointer; }
.more-button { font-size: 19px; }
.message-detail { border-bottom: 1px solid var(--line); padding-bottom: 28px; }
.message-detail h1 { font-size: clamp(28px, 7vw, 44px); line-height: 1.07; }
.sender-row { display: flex; gap: 12px; align-items: center; margin: 24px 0; }
.sender-avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: #ded7c8; font-weight: 800; }
.sender-row p, .sender-row strong, .sender-row small { margin: 0; display: block; }
.sender-row small { color: var(--muted); margin-top: 4px; font-size: 10px; }
.message-body { max-height: 44vh; overflow: auto; padding-right: 5px; color: #393630; font-size: 14px; line-height: 1.7; word-break: break-word; }
.draft-zone { padding-top: 22px; }
.draft-zone > p { color: var(--muted); text-align: center; font-size: 11px; }

.primary-button, .secondary-button { min-height: 50px; display: flex; align-items: center; justify-content: center; width: 100%; border: 0; border-radius: 14px; text-decoration: none; font-weight: 800; cursor: pointer; }
.primary-button { background: var(--ink); color: #fff; box-shadow: 0 8px 22px rgba(20, 19, 16, .18); }
.primary-button:hover { background: #2d2b26; }
.primary-button:disabled, .secondary-button:disabled { opacity: .45; cursor: not-allowed; }
.secondary-button { margin-top: 16px; border: 1px solid var(--ink); background: transparent; color: var(--ink); }
.magic { font-size: 15px; }
.send { background: var(--accent); }
.text-button { width: 100%; border: 0; background: none; padding: 15px; color: var(--muted); cursor: pointer; }

.draft-loading { display: flex; gap: 15px; align-items: center; padding: 19px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; }
.draft-loading span, .loading span { width: 25px; height: 25px; border: 2px solid #ccc5b8; border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
.draft-loading strong, .draft-loading p { display: block; margin: 0; }
.draft-loading p { margin-top: 4px; color: var(--muted); font-size: 11px; }
@keyframes spin { to { transform: rotate(360deg); } }
.draft-card { padding: 20px; border: 1px solid var(--line); border-radius: 18px; background: var(--card); box-shadow: var(--shadow); }
.draft-heading { display: flex; justify-content: space-between; align-items: center; }
.draft-heading h2 { margin: 0; font: 700 25px/1 Georgia, serif; }
.draft-heading > span, .setup-status { border-radius: 999px; padding: 6px 9px; background: #eee9df; color: var(--muted); font-size: 9px; font-weight: 800; }
.price-note, .notice-box { margin: 16px 0; padding: 13px; background: #f6e8d8; border-radius: 11px; color: #6b452a; font-size: 12px; line-height: 1.5; }
.price-note strong { display: block; color: #a84d2f; margin-bottom: 3px; }
.warning-list { margin: 14px 0; padding: 12px 12px 12px 30px; border-radius: 11px; background: #fff4dc; color: #735526; font-size: 12px; }
#draft-text { width: 100%; min-height: 280px; resize: vertical; border: 1px solid var(--line); border-radius: 12px; padding: 15px; color: var(--ink); background: #fff; font-size: 14px; line-height: 1.7; outline: none; }
#draft-text:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(239, 96, 66, .1); }
.tone-note { color: var(--muted); font-size: 11px; line-height: 1.5; }

.settings-head { align-items: center; }
.logout { color: var(--muted); font-size: 12px; }
.setup-card { display: grid; grid-template-columns: 34px 1fr; gap: 14px; padding: 22px 0; border-top: 1px solid var(--line); }
.step-number { width: 30px; height: 30px; display: grid; place-items: center; border: 1px solid var(--ink); border-radius: 50%; font: 700 13px Georgia, serif; }
.setup-copy h2 { margin: 9px 0 5px; font: 700 24px Georgia, serif; }
.setup-copy > p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.setup-status.done { color: var(--green); background: #dfeee7; }
.done-line { margin-top: 14px; color: var(--green); font-size: 12px; font-weight: 700; }
.ios-steps { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 16px 0 10px; }
.ios-steps div { min-height: 110px; padding: 13px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); }
.ios-steps b { color: var(--accent); }
.ios-steps p { margin: 10px 0 0; font-size: 11px; line-height: 1.55; }
.ios-note { font-size: 10px !important; }
.privacy-card { display: flex; gap: 13px; padding: 17px; border-radius: 14px; background: #e5e0d5; }
.privacy-card strong, .privacy-card p { display: block; margin: 0; }
.privacy-card p { color: var(--muted); font-size: 10px; line-height: 1.5; margin-top: 3px; }

.empty-state, .sent-state, .inbox-zero { text-align: center; padding: 14vh 12px 0; }
.empty-icon, .sent-state > div, .inbox-zero > div { width: 58px; height: 58px; margin: 0 auto 18px; border-radius: 50%; display: grid; place-items: center; background: var(--ink); color: #fff; font-size: 25px; }
.empty-state h1, .sent-state h1 { font-size: 38px; }
.empty-state > p:not(.eyebrow), .sent-state > p:not(.eyebrow), .inbox-zero p { color: var(--muted); font-size: 13px; line-height: 1.6; }
.empty-state .primary-button, .sent-state .primary-button { margin-top: 24px; }
.inbox-zero { padding: 80px 20px; }
.inbox-zero h2 { font: 700 25px Georgia, serif; margin: 0; }
.loading { min-height: 55vh; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); font-size: 12px; }
.loading span { width: 30px; height: 30px; }
.toast { position: fixed; z-index: 80; left: 50%; bottom: 95px; transform: translate(-50%, 20px); opacity: 0; width: max-content; max-width: calc(100% - 34px); padding: 12px 17px; border-radius: 999px; background: var(--ink); color: #fff; font-size: 12px; pointer-events: none; transition: .22s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #a83b2b; }

.login-page { display: grid; place-items: center; min-height: 100vh; padding: 22px; background: var(--ink); color: #f8f5ed; }
.login-card { width: min(100%, 460px); }
.login-mark { width: 58px; height: 58px; background: #f8f5ed; color: var(--ink); margin-bottom: 34px; }
.login-card .eyebrow { color: #ea8b72; }
.login-card h1 { margin: 0; font: 700 clamp(45px, 13vw, 64px)/.98 Georgia, serif; letter-spacing: -.05em; }
.login-copy { margin: 24px 0 35px; color: #aaa69d; font-size: 13px; line-height: 1.7; }
.login-card .primary-button { background: #f8f5ed; color: var(--ink); box-shadow: none; }
.login-card form label { display: block; color: #aaa69d; font-size: 11px; margin-bottom: 8px; }
.login-card input { width: 100%; height: 49px; border: 1px solid #4c4943; border-radius: 12px; background: #211f1c; color: #fff; padding: 12px; margin-bottom: 10px; }
.privacy-note { color: #77736c; font-size: 10px; text-align: center; margin-top: 22px; }

@media (min-width: 761px) {
  body { background: #ded9ce; }
  .app-shell { box-shadow: 0 0 70px rgba(0, 0, 0, .09); }
  main { padding-left: 34px; padding-right: 34px; }
}
