/* ============================================
   index.html — SPA 전용 스타일 (5열 레이아웃)
   ============================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  margin: 0 !important; padding: 0 !important;
  height: 100%; overflow: hidden;
}
body {
  font-family: 'Apple SD Gothic Neo','Malgun Gothic','맑은 고딕',-apple-system,sans-serif;
  font-size: 14px; color: #333;
  background: #f0f3f8;
}

/* ════════════════════════════════════════
   헤더 (전체 너비)
   ════════════════════════════════════════ */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 52px;
  background: #1a1a2e;
  display: flex; align-items: center;
  justify-content: space-between;
  /* 로고·메뉴 모두 광고컬럼 너비(≈11.11%)만큼 안쪽으로 */
  padding-left: calc(100% * 10 / 90);
  padding-right: calc(100% * 10 / 90);
  box-shadow: 0 2px 8px rgba(0,0,0,.35);
  z-index: 300;
}
.app-logo {
  font-size: 1.1rem; font-weight: 900;
  color: #e9c46a; text-decoration: none;
  white-space: nowrap; flex-shrink: 0;
}
.app-logo:hover { color: #fff; }

/* 헤더 내비게이션 */
.app-header-nav {
  display: flex; align-items: center; gap: 4px;
  flex-shrink: 0;
}
.app-nav-btn {
  background: transparent; border: none;
  color: #d0d8f0; font-size: .82rem; font-weight: 600;
  padding: 6px 10px; border-radius: 5px; cursor: pointer;
  transition: all .15s; white-space: nowrap;
}
.app-nav-btn:hover, .app-nav-btn:focus { background: rgba(255,255,255,.12); color: #e9c46a; outline: none; }
.app-header-nav .dropdown-menu {
  background: #1a1a2e; border: 1px solid #2d3a5a;
  min-width: 140px;
}
.app-header-nav .dropdown-item {
  color: #c8d2ea; font-size: .8rem; padding: 6px 14px;
}
.app-header-nav .dropdown-item:hover { background: rgba(233,196,106,.15); color: #e9c46a; }

/* ════════════════════════════════════════
   5열 바디 — position:fixed로 뷰포트 직접 채움
   body height/padding 영향 완전 차단
   ════════════════════════════════════════ */
.app-body {
  position: fixed;
  top: 52px; left: 0; right: 0; bottom: 0;
  display: flex; overflow: hidden;
}

/* ① ⑤ 광고 컬럼 */
.ad-col {
  flex: 10 10 0%;
  min-width: 0; min-height: 0;
  background: #f8f9fa;
  border-right: 1px solid #e0e6f0;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.ad-col-right { border-right: none; border-left: 1px solid #e0e6f0; }
.ad-col-inner {
  display: flex; flex-direction: column; align-items: center;
  padding: 6px 4px; height: 100%;
}
.ad-col-label {
  font-size: .58rem; color: #ccc; letter-spacing: 2px;
  align-self: flex-start; margin-bottom: 4px;
}

/* ② 좌측 패널 */
.left-col {
  flex: 10 10 0%;
  min-width: 0; min-height: 0;
  background: #fff; border-right: 1px solid #e0e6f0;
  display: flex; flex-direction: column;
  overflow-y: auto; overflow-x: hidden;
  scrollbar-width: none;
}
.left-col::-webkit-scrollbar { display: none; }

/* ════════════════════════════════════════
   미니 계산기
   ════════════════════════════════════════ */
.mini-calc {
  flex-shrink: 0; padding: 6px 6px 8px;
  border-bottom: 2px solid #e0e6f0;
}
.mc-label {
  font-size: .7rem; font-weight: 700; color: #777;
  margin-bottom: 5px; padding-left: 1px;
}
.mc-screen {
  background: #eef0f5; border-radius: 7px;
  border: 1px solid #d8dce8;
  padding: 6px 8px 8px; margin-bottom: 6px;
  min-height: 52px;
  display: flex; flex-direction: column; justify-content: space-between;
}
.mc-expr   { font-size: .77rem;  color: #dc2626; text-align: right; min-height: 14px; word-break: break-all; }
.mc-result { font-size: 1.16rem; font-weight: 800; color: #1a1a2e; text-align: right; line-height: 1.2; word-break: break-all; }
.mc-result-sub { font-size: .6rem; color: #888; font-weight: 400; }

.mc-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 3px;
}
.mc-btn {
  height: 30px; border: none; border-radius: 6px;
  font-size: .84rem; font-weight: 700; color: #1a1a2e;
  background: #f0f3f8;
  cursor: pointer; transition: background .1s, transform .08s;
  display: flex; align-items: center; justify-content: center;
}
.mc-btn:hover  { background: #e0e6f0; }
.mc-btn:active { transform: scale(.92); }
.mc-op  { background: #e8eeff; color: #2563eb; }
.mc-op:hover  { background: #d0dbff; }
.mc-ac  { background: #fee2e2; color: #dc2626; }
.mc-ac:hover  { background: #fecaca; }
.mc-eq  { background: #1a1a2e; color: #e9c46a; }
.mc-eq:hover  { background: #2d2d4e; }
.mc-act { background: #fef3c7; color: #92400e; }
.mc-act:hover { background: #fde68a; }
.mc-wide { grid-column: span 2; }

/* 메뉴 섹션 */
.menu-section { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.menu-title {
  font-size: .7rem; font-weight: 700; color: #aaa;
  padding: 8px 12px 4px; letter-spacing: .5px;
  border-bottom: 1px solid #f0f3f8;
}
.app-menu { flex: 1; min-height: 0; padding: 2px 0; overflow-y: hidden; }
.menu-item {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 12px; font-size: .84rem; color: #555; font-weight: 700;
  cursor: pointer; text-decoration: none;
  border-left: 3px solid transparent; transition: all .15s;
}
.menu-item i { font-size: .94rem; flex-shrink: 0; }
.menu-item:hover  { background: #f4f6fb; color: #1a1a2e; border-left-color: #c0cde0; }
.menu-item.active { background: #fff5f5; color: #dc2626; font-weight: 700; border-left-color: #dc2626; }

/* 하단 링크 */
.sidebar-footer {
  flex-shrink: 0; padding: 8px 12px;
  border-top: 1px solid #e0e6f0;
  display: flex; flex-direction: column; gap: 4px;
}
.sidebar-footer a { font-size: .78rem; color: #333; text-decoration: none; }
.sidebar-footer a:hover { color: #000; }
.sidebar-copyright {
  margin: 6px -12px -8px;
  padding: 6px 8px;
  background: #d8dce1;
  font-size: .6rem; color: #666;
  text-align: center; line-height: 1.4;
  word-break: keep-all;
}

/* ③ 메인 영역 */
.app-main {
  flex: 50 50 0%;
  min-width: 0; min-height: 0;
  display: flex; flex-direction: column; overflow: hidden;
  background: #f0f3f8;
}

/* ── 희망 문구 마퀴 ── */
.hope-marquee {
  flex-shrink: 0;
  height: 34px;
  background: #f1faf2;
  overflow: hidden;
  display: flex;
  align-items: center;
}
.hope-text {
  display: inline-block;
  padding-left: 100%;
  white-space: nowrap;
  color: #777;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  /* 애니메이션은 JS에서 동적으로 제어 */
}
@keyframes hopeScroll {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-100%); }
}

/* 서브탭 바 — 많을 경우 2줄 이상으로 자동 줄바꿈 */
.sub-tabs-bar {
  flex-shrink: 0;
  min-height: 56px; height: auto;
  background: #fff; border-bottom: 2px solid #e0e6f0;
  display: flex; flex-wrap: wrap;
  align-items: center; align-content: flex-start;
  padding: 8px 10px;
  gap: 6px;
  overflow: visible;
}

.sub-tab {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 8px 13px; border-radius: 6px;
  font-size: .76rem; font-weight: 600; cursor: pointer;
  border: 1.5px solid #e0e6f0; background: #f8faff; color: #555;
  flex-shrink: 0; white-space: nowrap; transition: all .15s;
}
.sub-tab i { font-size: .76rem; }
.sub-tab:hover  { background: #eef2ff; color: #1a1a2e; border-color: #b0bfe0; }
.sub-tab.active { background: #1a1a2e; color: #e9c46a; border-color: #1a1a2e; }

/* 메인 iframe */
/* 서브탭 아래 콘텐츠 광고 — 부모 컨텍스트에서 직접 표시 */
.main-content-ad {
  flex-shrink: 0;
  background: #f8f9fa;
  border-bottom: 1px solid #e0e6f0;
  overflow: hidden;
  min-height: 0;
}
.main-content-ad ins { display: block; }

.main-frame-wrap {
  flex: 1; min-height: 0;
  padding: 10px 14px 4px;
}
.main-frame-wrap iframe {
  width: 100%; height: 100%;
  border: none; display: block;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0,0,0,.1);
  background: #fff;
}

/* 하단 광고 */
.main-bottom-ad {
  flex-shrink: 0; height: 64px;
  margin: 8px 14px;
  background: #f8f9fa; border-radius: 6px; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}

/* ④ 우측 패널 */
.right-col {
  flex: 10 10 0%;
  min-width: 0; min-height: 0;
  background: #fff; border-left: 1px solid #e0e6f0;
  display: flex; flex-direction: column; overflow: hidden;
}

/* 하단 광고 박스 — util-widget 아래, 남은 공간 전체 */
.col-ad-wrap {
  flex: 1;
  min-height: 100px;
  overflow: hidden;
  transform: translate3d(0, 0, 0);
  position: relative;
  background: #f8f9fa;
  border-bottom: 2px solid #e0e6f0;
  padding: 4px 4px 6px;
  display: flex; flex-direction: column; align-items: center;
}
.col-ad-label {
  font-size: .56rem; color: #ccc; letter-spacing: 2px;
  align-self: flex-start; margin-bottom: 2px;
}

/* ════════════════════════════════════════
   유틸리티 위젯
   ════════════════════════════════════════ */
.util-widget { flex: 0 0 auto; display: flex; flex-direction: column; overflow: hidden; }

.util-tabs { display: flex; flex-shrink: 0; border-bottom: 2px solid #e0e6f0; }
.util-tab {
  flex: 1; padding: 8px 0;
  font-size: .79rem; font-weight: 700;
  border: none; background: #f8faff; color: #aaa;
  cursor: pointer; transition: all .15s;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
}
.util-tab:hover { color: #555; background: #f0f3f8; }
.util-tab.active { color: #1a1a2e; background: #fff; border-bottom-color: #e9c46a; }

.util-panel {
  display: none; flex: 1;
  flex-direction: column; padding: 10px 8px;
  overflow-y: auto;
}
.util-panel.active { display: flex; }

.util-display {
  font-size: 1.75rem; font-weight: 900; text-align: center;
  color: #1a1a2e; background: #f0f3f8; border-radius: 10px;
  padding: 10px 4px; margin-bottom: 9px;
  letter-spacing: 2px; font-variant-numeric: tabular-nums; line-height: 1;
}

.util-btns { display: flex; gap: 3px; flex-wrap: nowrap; margin-bottom: 5px; }
.util-btn {
  flex: 1; min-width: 0; padding: 6px 2px;
  border-radius: 6px; font-size: .76rem; font-weight: 700;
  border: 1.5px solid #e0e6f0; background: #f8faff; color: #555;
  cursor: pointer; transition: all .15s; white-space: nowrap;
  display: flex; align-items: center; justify-content: center; gap: 2px;
}
.util-btn:hover  { background: #1a1a2e; color: #e9c46a; border-color: #1a1a2e; }
.util-btn.primary { background: #1a1a2e; color: #e9c46a; border-color: #1a1a2e; }
.util-btn.danger  { background: #dc2626; color: #fff; border-color: #dc2626; }
.util-btn.danger:hover { background: #b91c1c; border-color: #b91c1c; }

.timer-input-wrap {
  display: flex; align-items: center; gap: 2px; margin-bottom: 7px;
}
.timer-input-wrap input {
  flex: 1; min-width: 0; padding: 5px 2px;
  border: 1.5px solid #e0e6f0; border-radius: 6px;
  font-size: .97rem; font-weight: 700; text-align: center; color: #1a1a2e;
}
.timer-input-wrap input:focus { outline: none; border-color: #1a1a2e; }
.timer-input-wrap span { font-size: .79rem; color: #888; flex-shrink: 0; }

.alarm-add-row { display: flex; gap: 4px; align-items: center; margin-bottom: 3px; }
.alarm-add-row .alarm-input { flex: 1; margin-bottom: 0; }
.alarm-add-btn { flex: 0 0 auto !important; padding: 6px 8px !important; }
.alarm-input {
  width: 100%; padding: 7px; border: 1.5px solid #e0e6f0; border-radius: 7px;
  font-size: 1.02rem; text-align: center; color: #1a1a2e;
  margin-bottom: 5px; font-weight: 700;
}
.alarm-input:focus { outline: none; border-color: #1a1a2e; }
.alarm-quick-row {
  display: grid; grid-template-columns: repeat(5, 1fr);
  gap: 2px; margin-bottom: 5px;
}
.alarm-quick-btn {
  padding: 4px 0; border-radius: 4px;
  font-size: .6rem; font-weight: 700; text-align: center;
  border: 1px solid #d0d8f0; background: #eef2ff; color: #3b5bdb;
  cursor: pointer; white-space: nowrap; overflow: hidden;
  transition: all .12s;
}
.alarm-quick-btn:hover { background: #1a1a2e; color: #e9c46a; border-color: #1a1a2e; }
.alarm-error { font-size: .75rem; color: #dc2626; text-align: center; min-height: 16px; margin-bottom: 3px; }
.alarm-list { flex: 0 0 auto; max-height: 100px; overflow-y: auto; margin-bottom: 5px; }
.alarm-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 5px 7px; border-radius: 7px;
  background: #f8faff; border: 1px solid #e0e6f0; margin-bottom: 4px;
}
.alarm-item-time { font-size: .83rem; font-weight: 700; color: #1a1a2e; }
.alarm-item-time i { font-size: .68rem; color: #e9c46a; margin-right: 3px; }
.alarm-item-cancel {
  background: none; border: none; color: #ccc;
  font-size: .88rem; cursor: pointer; padding: 0 2px; line-height: 1;
}
.alarm-item-cancel:hover { color: #dc2626; }
.alarm-empty { font-size: .78rem; color: #bbb; text-align: center; padding: 10px 0; }

.lap-list { flex: 1; overflow-y: auto; margin-top: 4px; font-size: .79rem; color: #555; }
.lap-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 4px 0; border-bottom: 1px solid #f0f3f8;
}
.lap-item:last-child { border-bottom: none; }

/* ── 모바일 (≤ 900px) ── */
@media (max-width: 900px) {
  body { overflow: auto; }
  .app-header { position: static; }
  .app-header-nav { display: none; }
  .app-body {
    position: static;
    flex-direction: column; overflow: auto;
  }

  .ad-col { display: none; }

  .left-col {
    flex: none; width: 100%; height: auto;
    flex-direction: row; overflow-x: auto;
    border-right: none; border-bottom: 1px solid #e0e6f0;
  }
  .mini-calc { display: none; }
  .menu-section { flex-direction: row; min-height: auto; }
  .menu-title { display: none; }
  .app-menu {
    display: flex; flex-direction: row; padding: 0;
    min-width: max-content; flex: 0 0 auto;
  }
  .menu-item { padding: 10px 14px; border-left: none; border-bottom: 3px solid transparent; }
  .menu-item.active { border-left-color: transparent; border-bottom-color: #dc2626; background: transparent; }
  .sidebar-footer { display: none; }

  .app-main { flex: none; overflow: visible; }
  .main-content-ad { display: none; }
  .main-frame-wrap { flex: none; padding: 8px 8px 0; }
  .main-frame-wrap iframe { height: 55vh; border-radius: 6px; }
  .main-bottom-ad { margin: 6px 8px; }

  .right-col { flex: none; width: 100%; border-left: none; border-top: 1px solid #e0e6f0; }
  .util-widget { max-height: 230px; }
  .col-ad-wrap { flex: 0 0 200px; }
  .util-display { font-size: 1.4rem; }
}
