:root {
  --bg: #fafafa;
  --panel: #ffffff;
  --line: #e7e7ea;
  --ink: #1a1a1e;
  --mute: #8a8a92;
  --accent: #b48a5a;      /* eonju warm tone */
  --accent-ink: #fff;
  --unread: #faf6f0;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", system-ui, sans-serif;
  color: var(--ink); background: var(--bg);
}
.hidden { display: none !important; }
button { font: inherit; cursor: pointer; }
.link { background: none; border: 0; color: var(--mute); text-decoration: underline; }
.link:hover { color: var(--ink); }
.err { color: #c0392b; min-height: 18px; font-size: 13px; margin-top: 8px; }

/* ---- login ---- */
.login { height: 100%; display: grid; place-items: center; }
.login-card {
  width: 320px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 36px 28px; text-align: center;
}
.brand { font-size: 22px; letter-spacing: .04em; margin: 0; }
.sub { color: var(--mute); margin: 2px 0 24px; letter-spacing: .3em; text-transform: uppercase; font-size: 11px; }
.login-card input {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line);
  border-radius: 8px; margin-bottom: 12px; font-size: 14px;
}
.login-card button {
  width: 100%; padding: 12px; border: 0; border-radius: 8px;
  background: var(--accent); color: var(--accent-ink); font-weight: 600;
}

/* ---- app shell ---- */
.app { height: 100%; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; height: 56px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.logo { font-weight: 700; letter-spacing: .02em; }
.logo span { color: var(--mute); font-weight: 400; margin-left: 4px; }
.acct { display: flex; align-items: center; gap: 14px; color: var(--mute); font-size: 13px; }

.body { flex: 1; display: grid; grid-template-columns: 220px 340px 1fr; min-height: 0; }

.sidebar { border-right: 1px solid var(--line); padding: 16px 12px; background: var(--panel); }
.compose {
  width: 100%; padding: 10px; border: 0; border-radius: 8px;
  background: var(--accent); color: var(--accent-ink); font-weight: 600; margin-bottom: 16px;
}
.folders { list-style: none; margin: 0; padding: 0; }
.folders li {
  padding: 9px 12px; border-radius: 8px; cursor: pointer;
  display: flex; justify-content: space-between; align-items: center;
}
.folders li:hover { background: var(--bg); }
.folders li.active { background: var(--unread); color: var(--accent); font-weight: 600; }
.count { font-size: 12px; color: var(--mute); }

.list { border-right: 1px solid var(--line); overflow-y: auto; background: var(--panel); }
.row {
  padding: 12px 16px; border-bottom: 1px solid var(--line); cursor: pointer;
}
.row:hover { background: var(--bg); }
.row.active { background: var(--unread); }
.row.unread .row-from, .row.unread .row-subj { font-weight: 700; }
.row-top { display: flex; justify-content: space-between; gap: 8px; }
.row-from { font-size: 13px; }
.row-date { font-size: 12px; color: var(--mute); white-space: nowrap; }
.row-subj { font-size: 13px; margin-top: 2px; }
.row-snip { font-size: 12px; color: var(--mute); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.reader { overflow-y: auto; padding: 28px 32px; }
.reader .r-subj { font-size: 20px; font-weight: 700; margin: 0 0 8px; }
.reader .r-meta { color: var(--mute); font-size: 13px; margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.reader .r-body { font-size: 14px; line-height: 1.7; }
.empty { color: var(--mute); padding: 40px; text-align: center; }

/* ---- compose modal ---- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.3); display: grid; place-items: center; z-index: 10; }
.modal-card { width: 560px; max-width: 92vw; background: var(--panel); border-radius: 12px; padding: 20px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; font-weight: 600; }
.modal-card input, .modal-card textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 10px; font: inherit;
}
.modal-card textarea { min-height: 220px; resize: vertical; }
.modal-foot { display: flex; align-items: center; gap: 12px; }
.modal-foot .compose { width: auto; padding: 10px 22px; margin: 0; }
.status { color: var(--mute); font-size: 13px; }

/* ---- mobile bottom tab bar (hidden on desktop) ---- */
.tabbar { display: none; }
.mback { display: none; }

/* ---- mobile ---- */
@media (max-width: 860px) {
  .body { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .list { display: block; padding-bottom: 72px; }   /* room for tab bar */
  .reader { display: none; padding: 20px 18px 84px; }
  .app.reading .list { display: none; }
  .app.reading .reader { display: block; }

  /* top bar: compact, address hidden */
  .topbar { padding: 0 16px; height: 52px; }
  .logo { font-size: 15px; }
  .acct #acct-addr { display: none; }           /* too long for phones */
  .acct { font-size: 12px; }

  /* back button shown while reading a message */
  .app.reading .mback { display: inline-flex; }
  .mback {
    align-items: center; gap: 6px; background: none; border: 0;
    color: var(--ink); font: 600 13px/1 inherit; padding: 10px 14px;
    position: sticky; top: 0; z-index: 5; background: var(--panel);
    width: 100%; border-bottom: 1px solid var(--line);
  }

  /* bottom tab bar */
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    background: var(--panel); border-top: 1px solid var(--line);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    justify-content: space-around; align-items: center;
  }
  .tabbar button {
    flex: 1; background: none; border: 0; color: var(--mute);
    font: 500 11px/1.3 inherit; padding: 6px 2px; display: flex;
    flex-direction: column; align-items: center; gap: 3px; cursor: pointer;
  }
  .tabbar button .ic { font-size: 19px; line-height: 1; }
  .tabbar button.active { color: var(--accent); }
  .tabbar .tb-count {
    position: absolute; transform: translate(14px,-4px);
    background: var(--accent); color: #fff; font-size: 9px; font-weight: 700;
    min-width: 15px; height: 15px; border-radius: 99px; padding: 0 4px;
    display: inline-flex; align-items: center; justify-content: center;
  }
  /* compose = center FAB-style tab */
  .tabbar .tb-compose .ic {
    background: var(--accent); color: #fff; width: 40px; height: 40px;
    border-radius: 50%; display: grid; place-items: center; font-size: 22px;
    margin-top: -14px; box-shadow: 0 4px 12px rgba(180,138,90,.4);
  }
  .tabbar .tb-compose { color: var(--accent); }

  /* compose modal full-screen on phone */
  .modal-card { width: 100vw; max-width: 100vw; height: 100svh; border-radius: 0;
    display: flex; flex-direction: column; }
  .modal-card textarea { flex: 1; min-height: 0; }
}
