:root{
  --brand:#FFB121;
  --brand-soft:rgba(255,177,33,.16);
  --line:#e7e9ee;
  --text:#1b1e26;
  --muted:#6b7280;
  --bg:#f3f4f6;
  --card:#fff;
}

*{box-sizing:border-box;margin:0;padding:0;font-family:Arial,sans-serif;}
body{background:var(--bg);color:var(--text);}

/* TOPBAR */
.topbar{background:#fff; position:sticky; top:0; z-index:999;}
.topbar-inner{
  max-width:1400px;
  margin:0 auto;
  padding:14px 18px;
  display:flex;
  align-items:center;
  gap:18px;
}
.brand img{height:34px; width:auto; cursor:pointer; display:block;}
.topmenu{display:flex; gap:16px; flex:1; align-items:center; flex-wrap:wrap;}
.topmenu a{
  text-decoration:none; color:#111; font-weight:900; padding:8px 10px; border-radius:10px;
}
.topmenu a:hover{background:var(--brand-soft);}
.top-actions{display:flex; gap:10px; align-items:center; flex-wrap:wrap;}
.mini-link{font-size:12px; color:#444; text-decoration:none;}
.mini-link:hover{text-decoration:underline;}
.brandline{height:4px; background:var(--brand);}

/* PORTAL GRID */
.portal{
  max-width:1400px;
  margin:16px auto;
  padding:0 18px 18px;
  display:grid;
  grid-template-columns:320px 1fr 300px;
  gap:14px;
}
.col{display:flex; flex-direction:column; gap:14px;}

.card{
  background:var(--card);
  border:1px solid var(--line);
  border-radius:12px;
  box-shadow:0 6px 20px rgba(0,0,0,.04);
  overflow:hidden;
}
.card-head{
  padding:10px 12px;
  font-weight:900;
  border-bottom:1px solid var(--line);
  background:#fff;
  position:relative;
}
.card-head::before{
  content:"";
  position:absolute;
  left:0; top:0; bottom:0;
  width:4px;
  background:var(--brand);
}

/* LEFT: LOGIN */
.login-box{padding:12px;}
.login-input{
  width:100%;
  padding:12px;
  border:1px solid var(--line);
  border-radius:12px;
  margin-top:10px;
  outline:none;
  background:#fff;
}
.login-input:focus{border-color:var(--brand); box-shadow:0 0 0 3px var(--brand-soft);}
.login-bottom{
  margin-top:10px;
  display:flex;
  justify-content:space-between;
  align-items:center;
  font-size:12px;
  color:var(--muted);
  gap:10px;
}
.links a{color:#111; text-decoration:none;}
.links a:hover{text-decoration:underline;}

.login-msg{margin-top:10px;font-size:12px;font-weight:900;}
.login-msg.bad{background:var(--brand-soft); padding:10px; border-radius:12px;}

.btn{
  border:1px solid var(--line);
  background:#fff;
  border-radius:12px;
  padding:10px 12px;
  font-weight:900;
  cursor:pointer;
}
.btn.brand{background:var(--brand); border-color:var(--brand); color:#fff; margin-top:10px; width:100%;}
.btn.brand:hover{opacity:.92;}
.btn.ghost{background:#fff;}
.btn.sm{padding:8px 10px; border-radius:10px; font-size:12px;}

/* USER PANEL */
#userPanel{padding:12px;}
.user-head{display:flex; align-items:center; gap:12px;}
.avatar{
  width:46px;height:46px;border-radius:14px;
  background:var(--brand-soft);
  border:1px solid rgba(255,177,33,.35);
  display:flex;align-items:center;justify-content:center;
}
.avatar::before{content:"👤";}
.user-meta{flex:1; min-width:0;}
.user-nick{display:flex; align-items:center; gap:8px; font-weight:900;}
#userNick{max-width:120px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
.badge{
  font-size:11px; font-weight:900;
  padding:3px 8px; border-radius:999px;
  background:var(--brand-soft);
  border:1px solid rgba(255,177,33,.35);
}
.user-id{margin-top:6px; font-size:12px; color:var(--muted);}

.user-stats{
  margin-top:12px;
  display:grid;
  grid-template-columns:1fr 1fr;
  border:1px solid var(--line);
  border-radius:12px;
  overflow:hidden;
  background:#fafafa;
}
.stat{padding:10px 12px;}
.stat + .stat{border-left:1px solid var(--line);}
.stat-label{font-size:12px;color:var(--muted);font-weight:900;}
.stat-value{margin-top:6px;font-weight:900; display:flex; gap:6px; align-items:center;}

.icon-row{margin-top:12px; display:flex; gap:8px;}
.icon-btn{
  flex:1;
  border:1px solid var(--line);
  background:#fff;
  border-radius:12px;
  padding:10px 0;
  cursor:pointer;
  font-weight:900;
}
.icon-btn:hover{border-color:var(--brand); box-shadow:0 0 0 3px var(--brand-soft);}
.icon-btn.home{background:var(--brand-soft); border-color:rgba(255,177,33,.6);}

/* CHAT */
.chat{padding:12px;}
.chat-top{display:flex; justify-content:space-between; align-items:center; gap:10px;}
.chip{display:inline-flex; gap:8px; align-items:center; font-weight:900; font-size:12px;}
.chat-icons{display:flex; gap:6px;}
.mini-ico{border:1px solid var(--line); background:#fff; border-radius:10px; padding:6px 8px; cursor:pointer;}
.mini-ico:hover{border-color:var(--brand);}
.chat-body{
  margin-top:10px;
  border:1px solid var(--line);
  border-radius:12px;
  padding:10px;
  height:220px;
  overflow:auto;
  background:#fff;
}
.chat-line{font-size:12px; color:#111; margin-bottom:8px;}
.chat-input{display:flex; gap:8px; margin-top:10px;}
.chat-input input{
  flex:1; padding:10px 12px;
  border:1px solid var(--line);
  border-radius:12px;
  outline:none;
}
.chat-input input:focus{border-color:var(--brand); box-shadow:0 0 0 3px var(--brand-soft);}

/* CENTER TOP ROW */
.row2{display:grid; grid-template-columns:1fr 1.2fr; gap:14px; margin-bottom:14px;}
.list{list-style:none; padding:10px 12px;}
.list li{padding:10px 0; border-bottom:1px dashed #eee; font-weight:800; color:#222;}
.list li:last-child{border-bottom:0;}
.dot{display:inline-block; width:8px; height:8px; border-radius:50%; background:var(--brand); margin-right:8px;}

/* TABS */
.tabs{display:flex; gap:6px; padding:10px 12px; border-bottom:1px solid var(--line); background:#fff; flex-wrap:wrap;}
.tab{
  border:1px solid var(--line);
  background:#fff;
  padding:8px 10px;
  border-radius:999px;
  font-weight:900;
  cursor:pointer;
}
.tab.active{border-color:var(--brand); background:var(--brand-soft);}
.tab:hover{border-color:var(--brand);}
.tab-body{padding:10px 12px;}
.post{padding:10px 0; border-bottom:1px solid #f0f0f0; font-weight:800;}
.post:last-child{border-bottom:0;}

/* PAGES + IFRAME */
.page{display:none;}
.page.active{display:block;}
.page-head{
  display:flex; align-items:center; gap:10px;
  margin:8px 0 10px;
  font-weight:900;
}
.page-head .bar{width:6px; height:18px; background:var(--brand); border-radius:999px;}

.iframe-wrap{
  border:1px solid var(--line);
  border-radius:12px;
  overflow:hidden;
  background:#fff;
}
.iframe-wrap iframe{width:100%; height:760px; border:0; display:block;}

/* HOME HERO / ADS */
.hero{height:240px; border-radius:12px; margin-bottom:14px;}
.hero.black{background:#111; display:flex; align-items:center; justify-content:center; color:#fff; font-weight:900;}
.grid-ads{display:grid; grid-template-columns:repeat(3,1fr); gap:12px;}
.adbox{height:90px; background:#fff; border:1px solid var(--line); border-radius:12px; display:flex; align-items:center; justify-content:center; font-weight:900;}

.ad-rect{height:360px; border:1px dashed #ddd; border-radius:12px; display:flex; align-items:center; justify-content:center; color:#777;}
.quick{display:grid; grid-template-columns:1fr; gap:10px; padding:12px;}
.qbtn{border:1px solid var(--line); border-radius:12px; padding:12px; font-weight:900; background:#fff; cursor:pointer;}
.qbtn:hover{border-color:var(--brand); box-shadow:0 0 0 3px var(--brand-soft);}

.footer{max-width:1400px;margin:14px auto 30px; padding:0 18px; color:#777; font-size:12px; text-align:center;}

@media (max-width:1100px){
  .portal{grid-template-columns:1fr;}
  .row2{grid-template-columns:1fr;}
  .grid-ads{grid-template-columns:1fr;}
}

/* ===== 태블릿 ===== */
@media (max-width: 1024px){
  .topbar-inner{
    flex-wrap: wrap;
    justify-content: center;
  }

  .topmenu{
    justify-content: center;
  }

  .top-actions{
    width: 100%;
    justify-content: center;
  }

  .portal{
    grid-template-columns: 1fr;
  }

  .row2{
    grid-template-columns: 1fr;
  }

  .grid-ads{
    grid-template-columns: 1fr 1fr;
  }

  .iframe-wrap iframe{
    height: 640px;
  }
}

/* ===== 모바일 ===== */
@media (max-width: 768px){
  body{
    font-size: 14px;
  }

  .topbar-inner{
    padding: 12px 14px;
    gap: 12px;
  }

  .brand img{
    height: 28px;
  }

  .topmenu{
    gap: 8px;
    justify-content: center;
  }

  .topmenu a{
    font-size: 13px;
    padding: 6px 8px;
  }

  .mini-link{
    font-size: 11px;
  }

  .portal{
    margin: 10px auto;
    padding: 0 10px 14px;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .card{
    border-radius: 10px;
  }

  .card-head{
    font-size: 14px;
    padding: 9px 10px;
  }

  .login-box,
  #userPanel,
  .chat,
  .tab-body{
    padding: 10px;
  }

  .login-input{
    height: 46px;
    font-size: 14px;
  }

  .btn{
    height: 44px;
    font-size: 14px;
  }

  .btn.sm{
    height: auto;
    padding: 8px 10px;
    font-size: 12px;
  }

  .login-bottom{
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .user-head{
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .user-stats{
    grid-template-columns: 1fr;
  }

  .icon-row{
    flex-wrap: wrap;
  }

  .icon-btn{
    min-width: 48px;
  }

  .tabs{
    gap: 6px;
  }

  .tab{
    font-size: 12px;
    padding: 7px 10px;
  }

  .grid-ads{
    grid-template-columns: 1fr;
  }

  .hero{
    height: 160px;
    font-size: 18px;
  }

  .ad-rect{
    height: 220px;
  }

  .iframe-wrap iframe{
    height: 520px;
  }

  .footer{
    font-size: 11px;
    padding: 0 10px;
  }
}

/* ===== 아주 작은 화면 ===== */
@media (max-width: 480px){
  .brand img{
    height: 24px;
  }

  .topmenu{
    gap: 4px;
  }

  .topmenu a{
    font-size: 12px;
    padding: 5px 6px;
  }

  .card-head{
    font-size: 13px;
  }

  .hero{
    height: 130px;
  }

  .iframe-wrap iframe{
    height: 420px;
  }
}

@media (max-width: 768px){
  .topbar-inner{
    flex-direction: column;
    align-items: center;
    gap: 10px;
  }

  .brand img{
    height: 42px;
  }

  .topmenu{
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    justify-items: center;
  }

  .topmenu a{
    display: block;
    width: 100%;
    text-align: center;
    font-size: 14px;
    padding: 10px 6px;
    white-space: nowrap;      /* ✅ 글자 줄바꿈 방지 */
    word-break: keep-all;     /* ✅ 한글 글자 쪼개짐 방지 */
  }

  .top-actions{
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
  }

  .mini-link{
    font-size: 12px;
    white-space: nowrap;
  }
}

@media (max-width: 480px){
  .topmenu{
    grid-template-columns: repeat(2, 1fr);
  }

  .topmenu a{
    font-size: 13px;
    padding: 9px 4px;
  }

  .brand img{
    height: 36px;
  }
}

/* ===== 모바일 상단 메뉴 강제 수정 ===== */
@media (max-width: 768px){
  .topbar{
    position: static !important;
  }

  .topbar-inner{
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 12px !important;
    padding: 14px 12px !important;
  }

  .brand{
    width: 100% !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
  }

  .brand img{
    height: 42px !important;
    width: auto !important;
    max-width: 220px !important;
  }

  .topmenu{
    flex: none !important;
    width: 100% !important;
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 8px !important;
    align-items: stretch !important;
    justify-items: stretch !important;
  }

  .topmenu a{
    display: block !important;
    width: 100% !important;
    text-align: center !important;
    font-size: 14px !important;
    line-height: 1.2 !important;
    padding: 10px 6px !important;
    white-space: nowrap !important;
    word-break: keep-all !important;
    overflow-wrap: normal !important;
  }

  .top-actions{
    width: 100% !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 12px !important;
    flex-wrap: wrap !important;
  }

  .mini-link{
    white-space: nowrap !important;
    font-size: 12px !important;
  }
}

@media (max-width: 480px){
  .topmenu{
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .topmenu a{
    font-size: 13px !important;
    padding: 9px 4px !important;
  }

  .brand img{
    height: 36px !important;
    max-width: 180px !important;
  }
}
