* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
  background: #0f172a;
  color: #e2e8f0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  height: 100vh;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  display: flex;
  flex-direction: column;
}

#app {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 16px 16px 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* 하단 탭바 */
.tab-bar {
  flex-shrink: 0;
  display: flex;
  background: #0b1120;
  border-top: 1px solid #1e293b;
  padding-bottom: env(safe-area-inset-bottom);
}
.tab-btn {
  flex: 1;
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: #475569;
  font-size: 11px;
  padding: 8px 0 7px;
  transition: color 0.15s;
}
.tab-btn .tab-ico { font-size: 22px; line-height: 1; filter: grayscale(0.6) opacity(0.6); transition: filter 0.15s; }
.tab-btn.active { color: #818cf8; }
.tab-btn.active .tab-ico { filter: none; }
.tab-panel { display: flex; flex-direction: column; }

/* 상단 타이틀바 여백 (hiddenInset) */
.titlebar-spacer { height: 20px; flex-shrink: 0; }

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.header h1 { font-size: 17px; font-weight: 600; color: #94a3b8; }
.btn-icon {
  background: none; border: none; cursor: pointer;
  font-size: 20px; padding: 4px; border-radius: 8px;
  transition: background 0.15s;
}
.btn-icon:hover { background: rgba(255,255,255,0.08); }

/* 설정 패널 */
.settings-panel {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 16px;
  display: none;
}
.settings-panel.open { display: block; }
.settings-panel h2 { font-size: 14px; font-weight: 600; color: #94a3b8; margin-bottom: 12px; }
.setting-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.setting-row:last-child { margin-bottom: 0; }
.setting-label { font-size: 13px; color: #cbd5e1; }
.setting-sub { font-size: 11px; color: #64748b; margin-top: 2px; }
.btn-small {
  background: #2563eb; color: white; border: none;
  padding: 5px 12px; border-radius: 8px; font-size: 12px; cursor: pointer;
}
.btn-small:hover { background: #1d4ed8; }
.tag-ok { font-size: 12px; color: #4ade80; }

/* 보정 */
.calibrate-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.calibrate-row select {
  background: #334155; color: white; border: none;
  border-radius: 8px; padding: 5px 8px; font-size: 12px; cursor: pointer;
}
.offset-note { font-size: 11px; color: #6366f1; margin-top: 6px; }

/* 메인 시계 카드 */
.clock-card {
  border-radius: 24px;
  padding: 28px 24px 24px;
  margin-bottom: 16px;
  text-align: center;
  transition: background 3s ease;
}
.clock-label { font-size: 12px; color: rgba(255,255,255,0.5); margin-bottom: 6px; }
.clock-icon { font-size: 36px; margin-bottom: 8px; }
.clock-time {
  display: flex; align-items: baseline; justify-content: center; gap: 10px;
  margin-bottom: 4px;
}
.clock-period { font-size: 18px; color: rgba(255,255,255,0.6); font-weight: 300; }
.clock-digits { font-size: 68px; font-weight: 200; color: white; letter-spacing: -2px; font-variant-numeric: tabular-nums; line-height: 1; }
.clock-seconds { font-size: 28px; font-weight: 200; color: rgba(255,255,255,0.4); margin-bottom: 8px; }

/* 진행 바 */
.progress-wrap { margin-top: 16px; }
.progress-meta { display: flex; justify-content: space-between; font-size: 11px; color: rgba(255,255,255,0.4); margin-bottom: 6px; }
.progress-bar-bg { width: 100%; height: 5px; background: rgba(0,0,0,0.3); border-radius: 4px; overflow: hidden; }
.progress-bar-fill { height: 100%; border-radius: 4px; transition: width 1s linear, background-color 3s ease; }
.progress-ticks { display: flex; justify-content: space-between; font-size: 10px; color: rgba(255,255,255,0.2); margin-top: 4px; }

/* 현실 시간 */
.real-time { text-align: center; font-size: 12px; color: #475569; margin-bottom: 20px; }
.real-time span { color: #64748b; }

/* 알람 */
.alarm-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.alarm-header h2 { font-size: 15px; font-weight: 600; color: #94a3b8; }
.btn-add {
  background: #4f46e5; color: white; border: none;
  padding: 7px 16px; border-radius: 12px; font-size: 13px;
  font-weight: 500; cursor: pointer; transition: background 0.15s;
}
.btn-add:hover { background: #4338ca; }

.alarm-empty { text-align: center; color: #334155; font-size: 13px; padding: 32px 0; line-height: 1.8; }

.alarm-item {
  display: flex; align-items: center; justify-content: space-between;
  background: #1e293b; border: 1px solid #334155;
  border-radius: 16px; padding: 14px 16px; margin-bottom: 10px;
  transition: opacity 0.2s;
}
.alarm-item.disabled { opacity: 0.45; }
.alarm-item.ringing {
  border-color: #ef4444;
  background: #3b1218;
  animation: alarmRow 0.7s ease-in-out infinite;
}
@keyframes alarmRow {
  0%, 100% { border-color: #ef4444; }
  50%      { border-color: #7f1d1d; }
}
.alarm-item.ringing .alarm-name { color: #fca5a5; }
.alarm-left { display: flex; align-items: center; gap: 12px; }
.alarm-emoji { font-size: 22px; }
.alarm-name { font-size: 14px; font-weight: 500; color: #e2e8f0; }
.alarm-sub { font-size: 12px; color: #64748b; margin-top: 2px; }
.alarm-right { display: flex; align-items: center; gap: 8px; }
.toggle {
  width: 44px; height: 24px; border-radius: 12px;
  border: none; cursor: pointer; position: relative;
  transition: background 0.2s; background: #334155;
}
.toggle.on { background: #4f46e5; }
.toggle-dot {
  position: absolute; top: 2px; width: 20px; height: 20px;
  background: white; border-radius: 10px; transition: transform 0.2s; transform: translateX(2px);
}
.toggle.on .toggle-dot { transform: translateX(22px); }
.btn-del {
  background: none; border: none; color: #475569;
  cursor: pointer; font-size: 16px; padding: 2px 4px;
  transition: color 0.15s; line-height: 1;
}
.btn-del:hover { color: #ef4444; }

/* 알람 발동 시 시계 카드 빨강 깜빡임 */
.clock-card.alarm-flash {
  animation: cardAlarm 0.7s ease-in-out infinite;
  cursor: pointer;
}
@keyframes cardAlarm {
  0%, 100% { background: #dc2626 !important; }
  50%      { background: #7f1d1d !important; }
}

/* ─── 교역 ─────────────────────────────── */
.trade-posts { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.trade-post-btn {
  flex: 1 1 calc(50% - 3px);
  background: #1e293b; border: 1.5px solid #334155; color: #94a3b8;
  border-radius: 12px; padding: 9px 6px; font-size: 12px; font-weight: 600;
  cursor: pointer; transition: all 0.15s; white-space: nowrap;
}
.trade-post-btn.active { background: #312e81; border-color: #6366f1; color: #c7d2fe; }
.trade-post-btn .tp-prog { display: block; font-size: 10px; font-weight: 400; color: #64748b; margin-top: 2px; }
.trade-post-btn.active .tp-prog { color: #818cf8; }

/* 티어별 / 스킬별 보기 전환 */
.view-toggle { display: flex; gap: 6px; margin-bottom: 12px; }
.view-toggle button {
  flex: 1; background: #1e293b; border: 1.5px solid #334155; color: #64748b;
  border-radius: 10px; padding: 8px 0; font-size: 13px; font-weight: 600; cursor: pointer;
}
.view-toggle button.on { background: #312e81; border-color: #6366f1; color: #c7d2fe; }
.view-toggle button { font-size: 12px; padding: 8px 2px; }

.all-summary {
  background: #172554; border: 1.5px solid #1e40af; color: #bfdbfe;
  border-radius: 12px; padding: 10px 14px; margin-bottom: 12px;
  font-size: 12px; text-align: center;
}
.all-summary b { color: #93c5fd; font-size: 14px; }

.tr-from {
  display: inline-block; font-size: 10px; color: #94a3b8;
  background: #0f172a; border-radius: 5px; padding: 2px 6px; margin-top: 4px;
}

.tier-card {
  background: #1e293b; border: 1.5px solid #334155;
  border-radius: 14px; margin-bottom: 10px; overflow: hidden;
}
.tier-card.done { border-color: #22c55e; }
.tier-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; cursor: pointer;
}
.tier-title { font-size: 13px; font-weight: 600; color: #e2e8f0; }
.tier-title .t-badge {
  display: inline-block; background: #334155; color: #94a3b8;
  border-radius: 6px; padding: 1px 6px; font-size: 11px; margin-right: 6px;
}
.tier-card.done .tier-title .t-badge { background: #14532d; color: #4ade80; }
.tier-sub { font-size: 11px; color: #64748b; margin-top: 2px; }
.tier-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.tier-prog { font-size: 12px; font-weight: 700; color: #64748b; font-variant-numeric: tabular-nums; }
.tier-card.done .tier-prog { color: #22c55e; }
.tier-arrow { color: #475569; font-size: 12px; transition: transform 0.2s; }
.tier-card.open .tier-arrow { transform: rotate(90deg); }
.tier-body { display: none; padding: 0 14px 12px; }
.tier-card.open .tier-body { display: block; }

.tr-mat { border-top: 1px solid #0f172a; padding: 10px 0 8px; }
.tr-mat:first-child { border-top: none; }
.tr-mat-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.tr-mat-name { font-size: 13px; font-weight: 600; color: #e2e8f0; }
.tr-mat.done .tr-mat-name { color: #4ade80; }
.tr-mat-count { font-size: 12px; color: #64748b; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tr-mat-count b { font-size: 14px; color: #fbbf24; }
.tr-mat.done .tr-mat-count b { color: #22c55e; }
.tr-mat-recipe { font-size: 11px; color: #6366f1; margin-top: 3px; line-height: 1.4; }
.tr-mat-recipe .rc-skill { color: #475569; }
.tr-mat-raw { font-size: 11px; color: #f59e0b; margin-top: 2px; line-height: 1.4; }
.tr-bar { height: 4px; background: #0f172a; border-radius: 3px; overflow: hidden; margin: 6px 0; }
.tr-bar > div { height: 100%; background: #fbbf24; border-radius: 3px; transition: width 0.2s; }
.tr-mat.done .tr-bar > div { background: #22c55e; }
.tr-ctrl { display: flex; gap: 4px; align-items: center; }
.tr-ctrl button {
  flex: 1; background: #334155; color: #cbd5e1; border: none;
  border-radius: 8px; padding: 7px 0; font-size: 12px; font-weight: 600; cursor: pointer;
}
.tr-ctrl button:active { background: #475569; }
.tr-ctrl input {
  width: 54px; background: #0f172a; color: #fbbf24; border: 1px solid #334155;
  border-radius: 8px; padding: 6px 4px; font-size: 13px; font-weight: 700;
  text-align: center; outline: none; -moz-appearance: textfield;
}
.tr-ctrl input::-webkit-outer-spin-button,
.tr-ctrl input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.tr-ctrl button.tr-max { flex: 0 0 auto; padding: 7px 10px; background: #14532d; color: #86efac; }

/* 원재료 총합 */
.raw-total {
  background: #1e293b; border: 1.5px solid #475569;
  border-radius: 14px; padding: 14px; margin-top: 4px; margin-bottom: 8px;
}
.raw-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.raw-title { font-size: 14px; font-weight: 700; color: #e2e8f0; }
.raw-sub { font-size: 11px; color: #64748b; margin-top: 2px; }
.raw-toggle {
  background: #334155; color: #cbd5e1; border: none; border-radius: 9px;
  padding: 6px 12px; font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.raw-toggle.on { background: #14532d; color: #86efac; }
.raw-list { display: flex; flex-direction: column; }
.raw-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 0; border-top: 1px solid #0f172a; font-size: 13px; color: #cbd5e1;
}
.raw-row:first-child { border-top: none; }
.raw-row b { color: #fbbf24; font-variant-numeric: tabular-nums; }
.raw-empty { text-align: center; color: #4ade80; font-size: 13px; padding: 16px 0; }

/* 미니 시계 버튼 */
.btn-mini-clock {
  width: 100%;
  background: #1e293b;
  border: 1.5px solid #334155;
  color: #cbd5e1;
  border-radius: 14px;
  padding: 12px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: 16px;
  transition: border-color 0.2s, color 0.2s;
}
.btn-mini-clock:hover { border-color: #475569; }
.btn-mini-clock.on { border-color: #818cf8; color: #818cf8; }

/* 마비노기 숙제 */
.hw-group-label { font-size: 12px; color: #64748b; font-weight: 600; margin-bottom: 8px; }
.hw-group-label span { color: #475569; font-weight: 400; }

.hw-item {
  display: flex; align-items: center; gap: 12px;
  background: #1e293b; border: 1.5px solid #334155;
  border-radius: 14px; padding: 12px 14px; margin-bottom: 8px;
  cursor: pointer; transition: border-color 0.2s, opacity 0.2s;
}
.hw-item.done { border-color: #22c55e; opacity: 0.55; }
.hw-check {
  width: 24px; height: 24px; border-radius: 7px;
  border: 2px solid #475569; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; color: white; transition: all 0.2s;
}
.hw-item.done .hw-check { background: #22c55e; border-color: #22c55e; }
.hw-name { flex: 1; font-size: 14px; color: #e2e8f0; }
.hw-item.done .hw-name { text-decoration: line-through; color: #64748b; }

/* 주간 카운터 */
.hw-counter-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.hw-cnt-btn {
  width: 30px; height: 30px; border-radius: 8px;
  border: none; background: #334155; color: white;
  font-size: 18px; cursor: pointer; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.hw-cnt-btn:active { background: #475569; }
.hw-cnt-val {
  font-size: 14px; font-weight: 700; color: #94a3b8;
  min-width: 46px; text-align: center; font-variant-numeric: tabular-nums;
}
.hw-item.done .hw-cnt-val { color: #22c55e; }

/* 작업 타이머 */
.task-card {
  display: flex; align-items: center; justify-content: space-between;
  background: #1e293b; border: 1.5px solid #334155;
  border-radius: 16px; padding: 14px 16px; margin-bottom: 10px;
  transition: border-color 0.3s;
}
.task-card.running { border-color: #22c55e; }
.task-card.done    { border-color: #f59e0b; }
.task-left { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.task-icon { font-size: 26px; flex-shrink: 0; }
.task-name { font-size: 13px; font-weight: 600; color: #e2e8f0; line-height: 1.4; }
.task-sub  { font-size: 11px; color: #64748b; margin-top: 2px; }
.task-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.task-countdown {
  font-size: 22px; font-weight: 700; color: #475569;
  font-variant-numeric: tabular-nums; min-width: 58px; text-align: right;
}
.task-card.running .task-countdown { color: #22c55e; }
.task-countdown.done { color: #f59e0b; font-size: 14px; font-weight: 600; }
.btn-task-start {
  background: #16a34a; color: white; border: none;
  padding: 7px 14px; border-radius: 10px; font-size: 13px;
  font-weight: 500; cursor: pointer; white-space: nowrap;
}
.btn-task-start:active { background: #15803d; }
.btn-task-reset {
  background: #475569; color: white; border: none;
  padding: 7px 14px; border-radius: 10px; font-size: 13px;
  font-weight: 500; cursor: pointer; white-space: nowrap;
}
.btn-task-reset:active { background: #334155; }
.task-progress-bar {
  width: 100%; height: 3px; background: #1e293b;
  border-radius: 0 0 14px 14px; margin-top: -2px; overflow: hidden;
}
.task-progress-fill {
  height: 100%; background: #22c55e; border-radius: 3px;
  transition: width 1s linear;
}

/* 경매장 시세 */
.market-card {
  background: #1e293b; border: 1.5px solid #334155;
  border-radius: 14px; padding: 12px 16px; margin-bottom: 10px;
  display: flex; align-items: center; justify-content: space-between;
}
.market-left { display: flex; align-items: center; gap: 10px; }
.market-icon { font-size: 22px; }
.market-name { font-size: 13px; font-weight: 600; color: #e2e8f0; }
.market-category { font-size: 11px; color: #475569; margin-top: 2px; }
.market-right { text-align: right; }
.market-price { font-size: 18px; font-weight: 700; color: #fbbf24; }
.market-price.none { font-size: 13px; color: #475569; font-weight: 400; }
.market-history { font-size: 11px; color: #64748b; margin-top: 2px; }
.market-card.failed { border-color: #7c3aed; opacity: 0.8; }
.market-option { font-size: 10px; color: #6366f1; margin-top: 3px; }
.market-loading { text-align: center; color: #475569; font-size: 13px; padding: 20px 0; }

/* 경매장 상세 */
.msearch-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0; border-bottom: 1px solid #1e293b;
}
.msearch-row:last-child { border-bottom: none; }

.mdetail-row {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid #1e293b;
}
.mdetail-row:last-child { border-bottom: none; }
.mdetail-num {
  width: 22px; height: 22px; border-radius: 50%;
  background: #334155; color: #94a3b8;
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.mdetail-info { flex: 1; }
.mdetail-price { font-size: 15px; font-weight: 700; color: #fbbf24; display: flex; align-items: center; gap: 6px; }
.mdetail-opts  { font-size: 11px; color: #6366f1; margin-top: 2px; }
.mdetail-meta  { font-size: 11px; color: #475569; margin-top: 2px; }

.footer-note { margin-top: 16px; font-size: 11px; color: #1e293b; text-align: center; line-height: 1.8; }

/* 알람 추가 모달 */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 40; opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.modal-backdrop.open { opacity: 1; pointer-events: all; }
.modal {
  background: #1e293b; width: 100%; border-radius: 24px 24px 0 0;
  padding: 20px 20px 32px; transform: translateY(100%); transition: transform 0.3s ease;
}
.modal-backdrop.open .modal { transform: translateY(0); }
.modal-handle { width: 40px; height: 4px; background: #475569; border-radius: 2px; margin: 0 auto 20px; }
.modal h3 { font-size: 17px; font-weight: 600; margin-bottom: 20px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12px; color: #94a3b8; margin-bottom: 6px; }
.form-group input, .form-group select {
  width: 100%; background: #334155; color: white; border: none;
  border-radius: 12px; padding: 12px 14px; font-size: 14px; outline: none;
}
.form-group input:focus, .form-group select:focus { box-shadow: 0 0 0 2px #4f46e5; }
.time-row { display: flex; gap: 10px; align-items: center; }
.time-row select { flex: 1; }
.time-sep { color: #64748b; font-size: 18px; }
.form-hint { font-size: 11px; color: #475569; margin-top: 6px; }
.btn-confirm {
  width: 100%; background: #4f46e5; color: white; border: none;
  padding: 15px; border-radius: 16px; font-size: 15px; font-weight: 600;
  cursor: pointer; margin-top: 8px; transition: background 0.15s;
}
.btn-confirm:hover { background: #4338ca; }

/* 알람 발동 오버레이 */
.alert-overlay {
  position: fixed; inset: 0; z-index: 50;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  cursor: pointer; opacity: 0; pointer-events: none;
  animation: none;
}
.alert-overlay.active {
  opacity: 1; pointer-events: all;
  animation: pulse-red 0.6s ease-in-out infinite;
}
@keyframes pulse-red {
  0%, 100% { background: #dc2626; }
  50% { background: #ef4444; }
}
.alert-bell { font-size: 80px; margin-bottom: 20px; animation: ring 0.4s ease-in-out infinite; }
@keyframes ring { 0%,100%{transform:scale(1)} 50%{transform:scale(1.1)} }
.alert-name { font-size: 34px; font-weight: 700; color: white; margin-bottom: 8px; }
.alert-time { font-size: 20px; color: rgba(255,255,255,0.85); margin-bottom: 32px; }
.alert-dismiss {
  background: rgba(255,255,255,0.2); color: white;
  border: none; padding: 12px 32px; border-radius: 32px;
  font-size: 16px; font-weight: 600; cursor: pointer;
}
