/* 링클래식 인공지능 — 밝은 화이트 테마 (가독성 우선) · PC/태블릿/모바일 */
:root{
  --bg:#eef0f4; --card:#ffffff; --line:#e5e7ee; --line2:#eef0f5;
  --ink:#15161a; --ink2:#5c6070; --ink3:#8b909c;
  --purple:#6d28d9; --purple-2:#7c3aed; --blue:#2563eb;
  --green:#12a63c; --green-bg:#e7f8ec; --amber:#b9760a; --amber-bg:#fff3df;
  --red:#d92d20; --red-bg:#fdecea; --dotori:#a86523;
  --radius:18px; --radius-s:12px; --radius-xs:9px;
  --shadow:0 1px 2px rgba(16,18,30,.04), 0 8px 24px rgba(16,18,30,.06);
  --shadow-l:0 12px 40px rgba(16,18,30,.14);
  --font:-apple-system,BlinkMacSystemFont,"Segoe UI","Malgun Gothic","Apple SD Gothic Neo",Roboto,sans-serif;
}
*{box-sizing:border-box; margin:0; padding:0}
html,body{min-height:100%}
body{ font-family:var(--font); color:var(--ink); background:var(--bg);
  -webkit-font-smoothing:antialiased; line-height:1.5; min-height:100vh; min-height:100dvh; }
.hidden{display:none !important}
.screen{min-height:100vh; min-height:100dvh}
b,strong{font-variant-numeric:tabular-nums}
img{max-width:100%}
.num{font-variant-numeric:tabular-nums}

.card{background:var(--card); border:1px solid var(--line); border-radius:var(--radius); box-shadow:var(--shadow)}

/* ---- 버튼 ---- */
.btn{font-family:inherit; font-size:15px; font-weight:700; letter-spacing:-.01em; border:none;
  border-radius:999px; padding:12px 22px; cursor:pointer; transition:.15s; white-space:nowrap}
.btn.primary{background:linear-gradient(135deg,var(--purple-2),var(--blue)); color:#fff;
  box-shadow:0 6px 16px rgba(109,40,217,.26)}
.btn.primary:hover{filter:brightness(1.06)}
.btn.primary:disabled{opacity:.5; cursor:default; box-shadow:none; filter:none}
.btn.ghost{background:#fff; color:var(--ink2); border:1px solid var(--line); padding:9px 15px; font-size:14px}
.btn.ghost:hover{background:var(--line2)}
.btn.mini{padding:8px 14px; font-size:13px}
.btn.danger{background:var(--red-bg); color:var(--red)}
.btn.danger:hover{background:#fbdcd8}
.btn.danger:disabled{opacity:.5; cursor:default}

/* ---- 입력 ---- */
.ipt{width:100%; padding:13px 15px; font-size:16px; font-family:inherit; color:var(--ink);
  background:#fbfbfd; border:1px solid var(--line); border-radius:var(--radius-s); transition:.15s}
.ipt::placeholder{color:#a3a7b2}
.ipt:focus{outline:none; background:#fff; border-color:var(--purple-2); box-shadow:0 0 0 4px rgba(124,58,237,.14)}

/* ---- 상단바 ---- */
.topbar{position:sticky; top:0; z-index:20; display:flex; align-items:center; justify-content:space-between;
  gap:12px; padding:12px 18px; padding-top:max(12px,env(safe-area-inset-top));
  background:rgba(255,255,255,.85); backdrop-filter:saturate(180%) blur(16px);
  border-bottom:1px solid var(--line)}
.tb-brand{display:flex; align-items:center; gap:9px; min-width:0}
.tb-brand img{width:26px; height:26px; flex:0 0 auto}
.tb-brand strong{font-size:16px; font-weight:750; letter-spacing:-.01em; white-space:nowrap; overflow:hidden; text-overflow:ellipsis}
.who{display:flex; align-items:center; gap:9px; flex:0 0 auto}
#whoName{font-size:14px; font-weight:700}
.badge{font-size:11px; font-weight:800; padding:4px 10px; border-radius:999px; color:#fff;
  background:linear-gradient(135deg,var(--purple-2),var(--blue))}

/* ---- 레이아웃 ---- */
.wrap{max-width:780px; margin:0 auto; padding:20px 16px 48px}
.card + .card{margin-top:16px}
.sect{padding:22px}
h2{font-size:16px; font-weight:750; letter-spacing:-.01em; display:flex; align-items:center; gap:9px}
h2 .h2ico{width:22px; height:22px; object-fit:contain}
.hint{color:var(--ink2); font-size:13px; margin:9px 0 16px; line-height:1.6}

/* ---- 내 캐릭터 ---- */
.me-card{padding:22px}
.hero{display:flex; align-items:center; gap:15px; margin-bottom:16px}
.avatar{width:60px; height:60px; flex:0 0 auto; border-radius:50%; display:grid; place-items:center;
  background:#f1eefc; border:1px solid var(--line)}
.avatar img{width:38px; height:38px; object-fit:contain}
.avatar.on{box-shadow:0 0 0 3px rgba(18,166,60,.35)}
.hero-main{min-width:0; flex:1}
.hero-name{font-size:22px; font-weight:800; letter-spacing:-.02em; color:var(--ink);
  display:flex; align-items:center; gap:9px; flex-wrap:wrap}
.hero-rank{font-size:12.5px; font-weight:800; padding:3px 11px; border-radius:999px;
  background:#f1eafe; color:var(--purple)}
.hero-sub{color:var(--ink2); font-size:14px; margin-top:3px; font-weight:600}

.pills{display:flex; flex-wrap:wrap; gap:7px; margin-bottom:16px}
.pill{font-size:12px; font-weight:750; padding:5px 12px; border-radius:999px; background:var(--line2); color:var(--ink2)}
.pill.on{background:var(--green-bg); color:var(--green)}
.pill.red{background:var(--red-bg); color:var(--red)}
.pill.blue{background:#e6efff; color:var(--blue)}
.pill.clan{background:var(--amber-bg); color:var(--amber)}

/* 스탯 그리드 (읽기 쉬운 라벨/값) */
.stats{display:grid; grid-template-columns:repeat(auto-fill,minmax(150px,1fr)); gap:12px 16px}
.stat{min-width:0}
.stat .k{font-size:12px; color:var(--ink2); font-weight:700; margin-bottom:2px}
.stat .v{font-size:15px; color:var(--ink); font-weight:750; letter-spacing:-.01em;
  font-variant-numeric:tabular-nums; word-break:keep-all; line-height:1.35}
.stat .v small{color:var(--ink3); font-weight:600; font-size:12px}

/* 전설 */
.legend{margin-top:16px}
.legend .sh{font-size:12.5px; font-weight:800; color:var(--ink2); margin-bottom:8px}
.lmark{background:var(--line2); border-left:3px solid var(--purple-2); border-radius:9px;
  padding:9px 13px; font-size:13.5px; font-weight:700; color:var(--ink); margin-bottom:7px}
.lmark:last-child{margin-bottom:0}

/* ---- 출석 / 도토리 ---- */
.dotori-card{padding:20px 22px}
.dotori-top{display:flex; align-items:center; gap:14px}
.dotori-ic{width:46px; height:46px; flex:0 0 auto}
.dotori-main{flex:1; min-width:0}
.dotori-num{font-size:26px; font-weight:850; color:var(--ink); letter-spacing:-.02em; line-height:1}
.dotori-num small{font-size:14px; color:var(--ink2); font-weight:700}
.dotori-sub{font-size:13px; color:var(--ink2); font-weight:600; margin-top:4px}
.dotori-badge{flex:0 0 auto; font-size:12.5px; font-weight:800; padding:8px 14px; border-radius:999px; text-align:center}
.dotori-badge.done{background:var(--green-bg); color:var(--green)}
.dotori-badge.wait{background:var(--amber-bg); color:var(--amber)}
.dotori-meta{display:flex; gap:10px; margin-top:14px; flex-wrap:wrap}
.dchip{flex:1 1 120px; background:var(--line2); border-radius:var(--radius-s); padding:11px 14px; text-align:center}
.dchip .k{font-size:11.5px; color:var(--ink2); font-weight:700}
.dchip .v{font-size:18px; color:var(--ink); font-weight:850; margin-top:2px}

/* ---- 인공지능 추가 ---- */
.add-row{display:flex; gap:10px; flex-wrap:wrap}
.add-row .ipt{flex:1 1 150px; min-width:0}
.add-row .btn{flex:0 0 auto; min-width:88px}
.err{color:var(--red); background:var(--red-bg); font-size:13px; font-weight:600; border-radius:9px;
  margin-top:0; padding:0; min-height:1px}
.err:not(:empty){padding:9px 12px; margin-top:11px}

/* ---- 인공지능 목록 ---- */
.list-head{display:flex; align-items:center; gap:9px; margin-bottom:14px}
.count{min-width:23px; height:23px; padding:0 8px; border-radius:999px; background:#f1eafe; color:var(--purple);
  font-size:12.5px; font-weight:800; display:inline-flex; align-items:center; justify-content:center}
.count:empty{display:none}
.bot-list{display:flex; flex-direction:column; gap:12px}
.bot{border:1px solid var(--line); border-radius:var(--radius-s); background:#fff; overflow:hidden; transition:.15s}
.bot.on{border-color:#bfe6cb; box-shadow:0 4px 14px rgba(18,166,60,.1)}
.bot.wait{border-color:#f2ddb2}
.bot.err{border-color:#f3c9c4}
.bot.off{opacity:.72}
.bot-row{display:flex; align-items:center; gap:13px; padding:14px 15px}
.bot-av{width:46px; height:46px; flex:0 0 auto; border-radius:50%; display:grid; place-items:center;
  background:#f1eefc; border:1px solid var(--line); position:relative}
.bot-av img{width:30px; height:30px; object-fit:contain}
.bot-av .dot{position:absolute; right:-2px; bottom:-2px; width:14px; height:14px; border-radius:50%;
  border:2.5px solid #fff; background:var(--ink3)}
.bot-av .dot.on{background:var(--green)} .bot-av .dot.wait{background:var(--amber)} .bot-av .dot.err{background:var(--red)}
.bot-main{flex:1; min-width:0}
.bot-nm{font-size:16px; font-weight:800; letter-spacing:-.01em; color:var(--ink); display:flex; align-items:center; gap:8px; flex-wrap:wrap}
.bot-nm .rk{font-size:12px; font-weight:800; padding:2px 9px; border-radius:999px; background:#f1eafe; color:var(--purple)}
.owner{font-size:11px; color:var(--ink3); font-weight:650; background:var(--line2); padding:2px 8px; border-radius:999px}
.bot-meta{font-size:12.5px; color:var(--ink2); margin-top:2px; font-weight:600}
.bot-st{font-size:12.5px; margin-top:5px; font-weight:750; display:flex; align-items:center; gap:6px; flex-wrap:wrap}
.bot-st .dt{width:7px; height:7px; border-radius:50%; background:currentColor; flex:0 0 auto}
.bot-st.on{color:var(--green)} .bot-st.wait{color:var(--amber)} .bot-st.err{color:var(--red)} .bot-st.off{color:var(--ink3)}
.bot-st .msg{color:var(--ink3); font-weight:600}
.bot-st .cool{background:var(--amber-bg); color:var(--amber); padding:1px 9px; border-radius:999px; font-size:11px}
.bot-actions{display:flex; align-items:center; gap:10px; flex:0 0 auto}

/* 토글 스위치 */
.switch{position:relative; width:46px; height:28px; flex:0 0 auto; cursor:pointer}
.switch input{opacity:0; width:0; height:0; position:absolute}
.switch .sl{position:absolute; inset:0; background:#d4d7e0; border-radius:999px; transition:.2s}
.switch .sl::before{content:""; position:absolute; width:22px; height:22px; left:3px; top:3px; background:#fff;
  border-radius:50%; transition:.2s; box-shadow:0 1px 3px rgba(0,0,0,.25)}
.switch input:checked + .sl{background:var(--green)}
.switch input:checked + .sl::before{transform:translateX(18px)}
.switch.cooling{opacity:.5; cursor:default}
.icon-btn{width:34px; height:34px; flex:0 0 auto; border:1px solid var(--line); background:#fff; color:var(--ink2);
  border-radius:9px; cursor:pointer; font-size:13px; display:grid; place-items:center; transition:.15s; line-height:1}
.icon-btn:hover{background:var(--line2)}
.icon-btn.danger{color:var(--red)} .icon-btn.danger:hover{background:var(--red-bg)}
.icon-btn:disabled{opacity:.4; cursor:default}

.bot-detail{padding:2px 15px 16px; border-top:1px solid var(--line2)}
.bot-detail .stats{margin-top:14px; grid-template-columns:repeat(auto-fill,minmax(128px,1fr))}
.empty{text-align:center; color:var(--ink3); padding:28px 0; font-size:14px}
.muted{color:var(--ink3); font-size:13px}

/* ---- 로그인 ---- */
#login{display:flex; align-items:center; justify-content:center; padding:24px}
.login-card{width:100%; max-width:400px; padding:38px 32px; text-align:center}
.login-brand{display:flex; align-items:center; justify-content:center; gap:11px; margin-bottom:6px}
.login-brand img{width:36px; height:36px}
.login-brand h1{font-size:23px; font-weight:800; letter-spacing:-.02em}
.login-brand h1 span{color:var(--purple)}
.login-sub{color:var(--ink2); font-size:14px; margin-bottom:22px}
#loginForm .ipt{margin-bottom:11px; text-align:left}
#loginForm .btn{width:100%; margin-top:5px}
.online-box{margin-top:24px; border-top:1px solid var(--line); padding-top:18px; text-align:left}
.online-h{display:flex; align-items:center; gap:8px; font-size:13.5px; font-weight:750; color:var(--ink2); margin-bottom:11px}
.online-h img{width:20px; height:20px}
.online-h b{color:var(--ink)}
.online-grid{list-style:none; display:flex; flex-wrap:wrap; gap:7px}
.online-grid li{background:var(--line2); color:var(--ink); padding:6px 12px; border-radius:999px; font-size:12.5px; font-weight:650}
.online-grid li.none{background:transparent; color:var(--ink3); padding-left:0}

/* ---- 토스트 ---- */
#toast{position:fixed; left:50%; bottom:26px; transform:translateX(-50%) translateY(12px);
  bottom:max(26px,calc(20px + env(safe-area-inset-bottom)));
  background:#15161a; color:#fff; padding:13px 22px; border-radius:999px; font-size:14px; font-weight:700;
  box-shadow:var(--shadow-l); opacity:0; transition:.26s; z-index:80; max-width:90vw; text-align:center}
#toast.show{opacity:1; transform:translateX(-50%) translateY(0)}
#toast.ok{background:var(--green)} #toast.bad{background:var(--red)} #toast.warn{background:var(--amber)}
#toast.dotori{background:linear-gradient(135deg,#b9760a,#a8611f)}

/* ---- 반응형 ---- */
@media (max-width:600px){
  .wrap{padding:16px 12px 40px}
  .sect,.me-card,.dotori-card{padding:18px 16px}
  .hero-name{font-size:20px}
  .avatar{width:54px; height:54px} .avatar img{width:34px; height:34px}
  .add-row{flex-direction:column}
  .add-row .ipt,.add-row .btn{width:100%}
  .stats{grid-template-columns:repeat(2,1fr)}
  .tb-brand strong{font-size:15px}
}
@media (max-width:360px){ .stats{grid-template-columns:1fr} }
