:root {
  --bg: #f4f5f7; --panel: #ffffff; --line: #e3e5ea; --text: #1f2430; --muted: #6b7280;
  --brand: #1b4fd8; --brand-ink: #ffffff; --sel: #eaf0ff; --unread: #0f2e8a; --danger: #c62828;
  --font: "Pretendard", "Malgun Gothic", "Apple SD Gothic Neo", "Segoe UI", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #14161b; --panel: #1c1f26; --line: #2c313b; --text: #e7e9ee; --muted: #9aa1ad; --brand: #4f7dff; --sel: #243052; --unread: #a9c1ff; --danger: #ff6b6b; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); }
.hidden { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 12.5px; } .tiny { font-size: 11.5px; }
.error { color: var(--danger); font-size: 13px; min-height: 1em; margin: 6px 0 0; }
.link { color: var(--brand); text-decoration: none; } .link:hover { text-decoration: underline; }
input, textarea { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; width: 100%; }
input:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 40%, transparent); border-color: var(--brand); }

.btn { font: inherit; display: inline-flex; align-items: center; justify-content: center; gap: 4px; padding: 7px 14px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--text); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 10px; font-size: 12.5px; }
.btn.danger { color: var(--danger); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }
.icon-btn { font: inherit; font-size: 17px; background: none; border: 0; color: var(--text); cursor: pointer; padding: 4px 8px; border-radius: 6px; }
.icon-btn:hover { background: var(--sel); }
.icon-btn.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.logo { background: var(--brand); color: #fff; font-weight: 800; padding: 1px 7px; border-radius: 5px; letter-spacing: .5px; }

/* 로그인 */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 28px; display: grid; gap: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.06); }
.login-card label { display: grid; gap: 4px; font-size: 13px; }
.brand-lg { font-size: 22px; font-weight: 700; }
.login-card p { margin: 0; }

/* 메인 레이아웃 */
.app { height: 100%; display: grid; grid-template-columns: 230px minmax(300px, 400px) 1fr; grid-template-rows: 52px minmax(0, 1fr); }
.topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; padding: 0 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 16px; white-space: nowrap; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 12px; min-width: 0; }
.who { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sidebar { background: var(--panel); border-right: 1px solid var(--line); padding: 14px; display: flex; flex-direction: column; gap: 14px; overflow: auto; }
.folders { display: grid; gap: 2px; }
.folder { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; border-radius: 6px; color: var(--text); text-decoration: none; }
.folder:hover { background: var(--bg); }
.folder.active { background: var(--sel); font-weight: 600; }
.badge { background: var(--brand); color: #fff; border-radius: 10px; padding: 0 7px; font-size: 11.5px; }
.local-card { margin-top: auto; border: 1px solid var(--line); border-radius: 8px; padding: 10px; display: grid; gap: 8px; background: var(--bg); }
.local-title { font-weight: 600; font-size: 13px; }
.local-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.ok { color: #1b8a3a; } .warn { color: #b26a00; }

.list-pane { min-height: 0; display: flex; flex-direction: column; border-right: 1px solid var(--line); min-width: 0; background: var(--panel); }
.list-head { display: flex; gap: 6px; padding: 10px; border-bottom: 1px solid var(--line); }
.list { overflow: auto; flex: 1; }
.item { padding: 10px 14px; border-bottom: 1px solid var(--line); cursor: pointer; display: grid; gap: 2px; }
.item:hover { background: var(--bg); }
.item.sel { background: var(--sel); }
.item .r1 { display: flex; gap: 8px; align-items: baseline; }
.item .who2 { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .dt { color: var(--muted); font-size: 12px; white-space: nowrap; }
.item .sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .snip { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item.unread .who2, .item.unread .sub { font-weight: 700; color: var(--unread); }
.item.unread { box-shadow: inset 3px 0 0 var(--brand); }
.list .note { padding: 30px 16px; text-align: center; color: var(--muted); }

.reader { min-width: 0; display: flex; flex-direction: column; background: var(--panel); overflow: hidden; }
.reader .empty { margin: auto; color: var(--muted); }
#readerBody { display: flex; flex-direction: column; height: 100%; padding: 14px 20px; gap: 10px; }
.reader-tools { display: flex; gap: 6px; flex-wrap: wrap; }
#rSubject { font-size: 19px; margin: 4px 0 0; word-break: break-word; }
.meta { font-size: 13px; display: grid; gap: 2px; word-break: break-all; }
.meta .k { display: inline-block; width: 72px; color: var(--muted); }
.atts { display: flex; flex-wrap: wrap; gap: 6px; }
.atts a { font-size: 12.5px; border: 1px solid var(--line); border-radius: 14px; padding: 3px 10px; color: var(--text); text-decoration: none; background: var(--bg); }
.atts a:hover { border-color: var(--brand); }
.frame { flex: 1; width: 100%; border: 1px solid var(--line); border-radius: 6px; background: #fff; min-height: 300px; }

/* 메일 쓰기 */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: grid; place-items: center; padding: 16px; z-index: 10; }
.compose { width: min(820px, 100%); height: min(680px, 100%); background: var(--panel); border-radius: 10px; display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.compose-head { display: flex; justify-content: space-between; align-items: center; }
.compose .row { display: grid; grid-template-columns: 74px 1fr; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.compose textarea { flex: 1; resize: none; line-height: 1.6; }
.compose-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spacer { flex: 1; }
.att-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { font-size: 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 2px 8px; display: inline-flex; gap: 6px; align-items: center; }
.chip button { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 0; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #222; color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 20; max-width: calc(100% - 32px); }

.only-mobile { display: none; }
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .only-mobile { display: inline-flex; }
  .sidebar { position: fixed; top: 52px; bottom: 0; left: 0; width: 260px; z-index: 5; transform: translateX(-100%); transition: transform .2s; box-shadow: 4px 0 20px rgba(0,0,0,.15); }
  .sidebar.open { transform: none; }
  .reader { display: none; }
  .app.reading .list-pane { display: none; }
  .app.reading .reader { display: flex; }
  #syncState, .who { display: none; }
  #readerBody { padding: 12px 16px; }
}
.vols{display:flex;flex-direction:column;gap:4px;margin-top:6px}
.vols a{display:flex;justify-content:space-between;gap:8px;color:inherit;text-decoration:none;word-break:break-all}
.vols a:hover{color:#1d4ed8}
.list .more{margin:12px auto;width:calc(100% - 24px)}
.local-card > * { min-width: 0; overflow-wrap: anywhere; }
.vols a span { flex-shrink: 0; }
.pw-wrap{position:relative;display:block}
.pw-wrap input{padding-right:40px}
.pw-eye{position:absolute;right:4px;top:50%;transform:translateY(-50%);border:0;background:none;cursor:pointer;font-size:16px;opacity:.6;padding:4px 6px}
.pw-eye.on{opacity:1}

.install-btn{margin-top:4px}
.install-card{max-width:520px;height:auto;max-height:100%}
.install-body{padding:4px 2px;overflow:auto}
.install-body h3{font-size:15px;margin:14px 0 6px}
.install-body ol{padding-left:20px;margin:8px 0}
.install-body li{margin:4px 0}
.install-body section{border-top:1px solid var(--line);padding-top:4px}
.install-body section:first-child{border-top:0}
.login-top{display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap}
.lang-switch{display:inline-flex;align-items:center;border:1px solid var(--line);border-radius:8px;overflow:hidden;font-size:12.5px}
.lang-switch .lang-ico{padding:0 4px 0 8px;opacity:.7}
.lang-switch button{border:0;background:none;color:var(--muted);padding:5px 10px;cursor:pointer;font:inherit}
.lang-switch button.on{background:var(--brand);color:#fff}
.lang-select{border:1px solid var(--line);background:var(--panel);color:var(--text);border-radius:6px;padding:5px 6px;font:inherit;font-size:13px;cursor:pointer}
.ed-tools{display:flex;align-items:center;gap:2px;flex-wrap:wrap;border:1px solid var(--line);border-bottom:0;border-radius:6px 6px 0 0;padding:4px 6px;background:var(--bg);margin-bottom:-8px}
.ed-tools button,.ed-tools label{border:0;background:none;color:var(--text);min-width:30px;height:28px;border-radius:4px;cursor:pointer;font:inherit;font-size:14px;display:inline-flex;align-items:center;justify-content:center;padding:0 6px}
.ed-tools button:hover,.ed-tools label:hover{background:var(--line)}
.ed-color{position:relative;font-weight:700;text-decoration:underline;text-decoration-color:#d32f2f;text-decoration-thickness:3px}
.ed-color input{position:absolute;inset:0;opacity:0;cursor:pointer;width:100%;height:100%}
.ed-sep{width:1px;height:18px;background:var(--line);margin:0 4px}
.ed-hint{margin-left:auto;padding-left:8px}
.editor{flex:1;min-height:160px;overflow:auto;border:1px solid var(--line);border-radius:0 0 6px 6px;padding:10px 12px;background:var(--panel);color:var(--text);font:14px/1.6 'Malgun Gothic',Arial,sans-serif;outline:none;word-break:break-word}
.editor:focus{border-color:var(--brand)}
.editor:empty::before{content:attr(data-ph);color:var(--muted);pointer-events:none}
.editor img{max-width:100%;height:auto;cursor:default}
.editor img.sel{outline:2px solid var(--brand)}
.editor blockquote{margin:8px 0 0;padding-left:10px;border-left:3px solid var(--line)}
.editor.drag{background:var(--sel)}
@media (max-width:900px){.ed-hint{display:none}}
.dev-card{margin-top:auto}
.dev-card + .local-card{margin-top:0}
.dev-row{display:flex;align-items:center;gap:6px;font-size:12.5px;cursor:pointer}
.dev-row select{margin-left:auto;border:1px solid var(--line);background:var(--panel);color:var(--text);border-radius:5px;padding:2px 4px;font:inherit;font-size:12px}
.offbar{display:flex;align-items:center;gap:8px;justify-content:space-between;background:#fff4e0;color:#7a4b00;border-bottom:1px solid #f1d29a;padding:8px 12px;font-size:12.5px}
@media (prefers-color-scheme: dark){:root:not([data-theme="light"]) .offbar{background:#3a2a0f;color:#ffd58a;border-color:#5a4214}}
.item.notsaved{opacity:.55}
.atts .nosave{font-size:12.5px;border:1px dashed var(--line);border-radius:14px;padding:3px 10px;color:var(--muted)}
html,body{overflow-x:hidden}
.side-mobile{flex-direction:column;gap:8px}
.side-mobile .lang-select,.side-mobile .btn{width:100%}
@media (max-width:900px){
  .side-mobile.only-mobile{display:flex}
  .topbar{min-width:0;overflow:hidden}
  .topbar .lang-select,#installBtn2,.brand .ver{display:none !important}
  .top-right{min-width:0;flex-shrink:1}
  .list-head{min-width:0}
  .list-head input{min-width:0}
}
.local-card .dev-row{display:flex !important;flex-direction:row;align-items:center;gap:8px;margin:0}
.local-card .dev-row input[type=checkbox]{width:16px;height:16px;flex:none;margin:0;padding:0}
.local-card .dev-row > span{flex:1;text-align:left}
.local-card .dev-row select{width:auto;flex:none}
.login-card label.chk{display:flex;align-items:center;gap:8px;font-size:12.5px;cursor:pointer}
.login-card label.chk input{width:16px;height:16px;flex:none;margin:0;padding:0}
