/* ═══════════════════════════════════════════════════════════════════════════
   Toolbox Extension — CSS
   Design language matches PicWall: #1a1d27 backgrounds, rgba(255,255,255,...)
   text, #6366f1/#8b5cf6 accent, gold #ffd700. All prefixed tb_ .
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Shared overlay ──────────────────────────────────────────────────────── */
.tb_overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.75); z-index: 9500;
    display: flex; align-items: center; justify-content: center; backdrop-filter: blur(4px);
}

/* ── Shared modal head — identical to .pw_modal_head ────────────────────── */
.tb_modal_head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px; border-bottom: 1px solid rgba(255,255,255,0.06);
    font-weight: 700; font-size: 15px; color: #fff; flex-shrink: 0;
}
.tb_modal_head .tb_progress_label { font-size: 12px; font-weight: 400; color: rgba(255,255,255,0.35); }
.tb_modal_close { cursor: pointer; color: rgba(255,255,255,0.4); padding: 4px 8px; border-radius: 6px; transition: all 0.15s; font-size: 14px; }
.tb_modal_close:hover { color: #fff; background: rgba(255,255,255,0.08); }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.tb_btn { padding: 7px 16px; border-radius: 20px; cursor: pointer; font-size: 13px; font-weight: 600; transition: all 0.2s; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; border: none; font-family: inherit; }
.tb_btn_ghost { background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.7); }
.tb_btn_ghost:hover { background: rgba(255,255,255,0.12); color: #fff; }
.tb_btn_confirm, .tb_btn_finish { background: linear-gradient(135deg,#6366f1,#8b5cf6); color: #fff; }
.tb_btn_confirm:hover, .tb_btn_finish:hover { background: linear-gradient(135deg,#818cf8,#a78bfa); transform: translateY(-1px); }
.tb_btn_finish:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.tb_btn_share { background: rgba(255,215,0,0.10); color: #ffd700; border: 1px solid rgba(255,215,0,0.18); }
.tb_btn_share:hover { background: rgba(255,215,0,0.18); }
.tb_btn_share:disabled { opacity: 0.5; cursor: not-allowed; }
.tb_btn_done { background: rgba(34,197,94,0.15) !important; color: #22c55e !important; border-color: rgba(34,197,94,0.2) !important; }
.tb_gold_icon { width: 14px; height: 14px; vertical-align: middle; }
.tb_spinner { text-align: center; padding: 40px; font-size: 26px; color: rgba(255,255,255,0.25); }
.tb_err { color: rgba(255,255,255,0.4); text-align: center; padding: 20px; font-size: 13px; }

/* ═══════════════════════════════════════════════════════════════════════════ LAUNCHER */
.tb_launcher_box { background: #1a1d27; border-radius: 14px; width: 520px; max-width: 95vw; max-height: 85vh; display: flex; flex-direction: column; border: 1px solid rgba(255,255,255,0.08); box-shadow: 0 20px 60px rgba(0,0,0,0.5); overflow: hidden; }
.tb_launcher_tools { display: flex; flex-wrap: wrap; gap: 12px; padding: 18px; overflow-y: auto; }
.tb_tool_card { display: flex; flex-direction: column; align-items: center; width: 120px; padding: 18px 10px 14px; border-radius: 12px; border: 1px solid rgba(255,255,255,0.08); background: rgba(255,255,255,0.04); cursor: pointer; transition: all 0.2s; text-align: center; }
.tb_tool_card:hover { border-color: rgba(99,102,241,0.5); background: rgba(99,102,241,0.08); transform: translateY(-2px); }
.tb_tool_icon { font-size: 1.8rem; color: #8b5cf6; margin-bottom: 8px; }
.tb_tool_name { font-size: 12px; font-weight: 700; color: rgba(255,255,255,0.85); margin-bottom: 5px; }
.tb_tool_desc { font-size: 11px; color: rgba(255,255,255,0.3); line-height: 1.4; }

.tb_section_head { padding: 10px 16px; font-size: 11px; font-weight: 700; color: rgba(255,255,255,0.45); letter-spacing: 0.08em; text-transform: uppercase; border-bottom: 1px solid rgba(255,255,255,0.06); display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.tb_back_arrow { cursor: pointer; color: rgba(255,255,255,0.4); transition: color 0.15s; }
.tb_back_arrow:hover { color: #fff; }
#tb_collage_section { display: flex; flex-direction: column; flex: 1; overflow: hidden; }
.tb_tpl_grid { display: flex; flex-wrap: wrap; gap: 12px; padding: 16px; overflow-y: auto; flex: 1; }
.tb_tpl_card { width: 210px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.08); background: rgba(255,255,255,0.03); cursor: pointer; overflow: hidden; transition: all 0.2s; }
.tb_tpl_card:hover { border-color: rgba(99,102,241,0.5); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.3); }
.tb_tpl_preview { width: 100%; display: block; aspect-ratio: 1280/800; object-fit: cover; background: rgba(0,0,0,0.2); }
.tb_tpl_info { padding: 10px 12px; }
.tb_tpl_name { font-size: 13px; font-weight: 700; color: rgba(255,255,255,0.85); margin-bottom: 4px; }
.tb_tpl_cost { font-size: 12px; color: #ffd700; display: flex; align-items: center; gap: 4px; font-weight: 600; }

/* ═══════════════════════════════════════════════════════════════════════════ EDITOR */
.tb_editor_box { background: #1a1d27; border-radius: 14px; max-width: min(1320px,98vw); max-height: 92vh; width: 100%; display: flex; flex-direction: column; border: 1px solid rgba(255,255,255,0.08); box-shadow: 0 20px 60px rgba(0,0,0,0.5); overflow: hidden; }
.tb_canvas_wrap { position: relative; align-self: center; margin: 8px auto 0; border: 1px solid rgba(255,255,255,0.08); box-shadow: 0 4px 24px rgba(0,0,0,0.4); background: #000; flex-shrink: 0; max-width: 100%; overflow: hidden; }
#tb_canvas { display: block; max-width: 100%; max-height: calc(92vh - 160px); }

.tb_slot_target { position: absolute; cursor: pointer; border: 2px dashed transparent; transition: background 0.18s, border-color 0.18s; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 3px; }
.tb_slot_target:hover { background: rgba(99,102,241,0.18); border-color: rgba(99,102,241,0.6); }
.tb_slot_target.tb_slot_filled:hover { background: rgba(99,102,241,0.08); border-color: rgba(99,102,241,0.35); }
.tb_slot_target.tb_slot_drag { background: rgba(99,102,241,0.28) !important; border-color: #6366f1 !important; border-style: solid !important; }
.tb_slot_icon { font-size: 1.5rem; color: rgba(255,255,255,0.4); pointer-events: none; text-shadow: 0 1px 4px rgba(0,0,0,0.5); transition: opacity 0.18s; }
.tb_slot_label { font-size: 0.58rem; color: rgba(255,255,255,0.35); pointer-events: none; letter-spacing: 0.08em; text-transform: uppercase; text-shadow: 0 1px 4px rgba(0,0,0,0.6); transition: opacity 0.18s; }
.tb_slot_filled .tb_slot_icon, .tb_slot_filled .tb_slot_label { opacity: 0; }

.tb_editor_scroll { flex: 1; overflow-y: auto; display: flex; flex-direction: column; min-height: 0; }
.tb_name_row { display: flex; align-items: center; gap: 10px; padding: 10px 16px 0; flex-shrink: 0; }
.tb_name_row label { font-size: 12px; font-weight: 600; color: rgba(255,255,255,0.5); white-space: nowrap; text-transform: uppercase; letter-spacing: 0.06em; }
.tb_name_input { padding: 8px 12px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.10); background: rgba(255,255,255,0.04); color: #fff; font-size: 13px; width: 200px; outline: none; transition: border-color 0.2s; font-family: inherit; }
.tb_name_input:focus { border-color: rgba(99,102,241,0.6); }
.tb_name_input::placeholder { color: rgba(255,255,255,0.25); }

.tb_editor_footer { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 12px 16px; border-top: 1px solid rgba(255,255,255,0.06); flex-shrink: 0; }

/* ═══════════════════════════════════════════════════════════════════════════ CROP */
.tb_crop_overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.85); z-index: 9600; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(6px); }
.tb_crop_box { background: #1a1d27; border-radius: 14px; max-width: 92vw; max-height: 92vh; display: flex; flex-direction: column; border: 1px solid rgba(255,255,255,0.08); box-shadow: 0 20px 60px rgba(0,0,0,0.6); overflow: hidden; }
.tb_crop_container { flex: 1; overflow: hidden; max-width: 90vw; max-height: 68vh; }
.tb_crop_container img { display: block; max-width: 88vw; max-height: 66vh; }
.tb_crop_footer { display: flex; gap: 10px; padding: 12px 16px; border-top: 1px solid rgba(255,255,255,0.06); justify-content: flex-end; flex-shrink: 0; }

/* ═══════════════════════════════════════════════════════════════════════════ RESULT */
.tb_result_overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.85); z-index: 9700; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(6px); }
.tb_result_box { background: #1a1d27; border-radius: 14px; max-width: min(860px,94vw); width: 100%; display: flex; flex-direction: column; border: 1px solid rgba(255,255,255,0.08); box-shadow: 0 20px 60px rgba(0,0,0,0.6); overflow: hidden; }
.tb_result_preview { width: 100%; display: block; max-height: 60vh; object-fit: contain; background: #0e1117; }
.tb_result_footer { display: flex; flex-wrap: wrap; gap: 10px; padding: 14px 16px; border-top: 1px solid rgba(255,255,255,0.06); justify-content: center; }

/* ═══════════════════════════════════════════════════════════════════════════ RESPONSIVE */
@media (max-width: 600px) {
    .tb_launcher_box, .tb_editor_box, .tb_result_box { border-radius: 0; max-width: 100vw; max-height: 100vh; }
    .tb_tpl_card  { width: calc(50% - 6px); }
    .tb_tool_card { width: calc(50% - 6px); }
    .tb_editor_footer, .tb_result_footer, .tb_crop_footer { flex-direction: column; }
    .tb_btn { width: 100%; justify-content: center; }
    .tb_name_row { flex-direction: column; align-items: flex-start; }
    .tb_name_input { width: 100%; }
    .tb_canvas_wrap { margin: 6px 0 0; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   CAPTION TOOL
   ═══════════════════════════════════════════════════════════════════════════ */

.tc_editor_box { max-width: min(680px, 97vw) !important; }

/* Upload zone */
.tc_upload_zone {
    position: relative; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 12px;
    min-height: 220px; margin: 14px; border-radius: 10px;
    border: 2px dashed rgba(255,255,255,0.1); cursor: pointer;
    background: rgba(255,255,255,0.02); transition: border-color .2s, background .2s;
}
.tc_upload_zone:hover, .tc_upload_zone.tc_drag_over {
    border-color: rgba(99,102,241,0.55); background: rgba(99,102,241,0.05);
}
.tc_upload_icon { font-size: 2.4rem; color: rgba(255,255,255,0.15); }
.tc_upload_text { font-size: 13px; color: rgba(255,255,255,0.3); }

/* Canvas */
.tc_canvas_col {
    display: flex; justify-content: center;
    padding: 12px 14px 0; background: rgba(0,0,0,0.2);
}
.tc_canvas_wrap {
    border: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 4px 20px rgba(0,0,0,0.5); line-height: 0;
}
#tc_canvas { display: block; cursor: crosshair; max-width: 100%; }

/* Lines panel */
.tc_panel {
    padding: 10px 14px 6px;
    border-top: 1px solid rgba(255,255,255,0.06);
}
.tc_panel_header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 8px;
}
.tc_panel_title {
    font-size: 11px; font-weight: 700; letter-spacing: .07em;
    text-transform: uppercase; color: rgba(255,255,255,0.3);
}
.tc_sm_btn { font-size: 11px !important; padding: 4px 10px !important; border-radius: 6px !important; }

/* Lines list */
.tc_lines_list { display: flex; flex-direction: column; gap: 6px; }

.tc_line_row {
    border-radius: 8px; padding: 8px 10px;
    border: 1px solid rgba(255,255,255,0.06);
    background: rgba(255,255,255,0.02);
    transition: border-color .15s;
}
.tc_line_row.tc_line_active {
    border-color: rgba(99,102,241,0.45);
    background: rgba(99,102,241,0.06);
}

/* Top row: number + text input + caps + delete */
.tc_row_top {
    display: flex; align-items: center; gap: 7px; margin-bottom: 7px;
}
.tc_row_num {
    font-size: 10px; font-weight: 700; color: rgba(255,255,255,0.2);
    width: 14px; text-align: center; flex-shrink: 0;
}
.tc_row_text {
    flex: 1; background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.1); border-radius: 6px;
    color: rgba(255,255,255,0.9); font-size: 13px;
    padding: 5px 9px; outline: none; font-family: inherit; min-width: 0;
}
.tc_row_text:focus {
    border-color: rgba(99,102,241,0.5); background: rgba(99,102,241,0.07);
}
.tc_caps_btn {
    font-size: 11px; font-weight: 800; padding: 4px 8px; border-radius: 5px;
    border: 1px solid rgba(255,255,255,0.12); color: rgba(255,255,255,0.3);
    background: transparent; cursor: pointer; transition: all .15s; flex-shrink: 0;
    white-space: nowrap;
}
.tc_caps_btn.tc_caps_on {
    background: rgba(99,102,241,0.2); color: #a78bfa; border-color: rgba(99,102,241,0.5);
}
.tc_del_btn {
    background: transparent; border: none; color: rgba(255,255,255,0.2);
    cursor: pointer; font-size: 12px; padding: 3px 5px; flex-shrink: 0;
    transition: color .15s; border-radius: 4px;
}
.tc_del_btn:hover { color: #f87171; background: rgba(248,113,113,0.08); }

/* Controls row: size + colors */
.tc_row_controls {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.tc_ctrl_label {
    font-size: 10px; color: rgba(255,255,255,0.25); white-space: nowrap;
}
.tc_size_slider {
    flex: 1; min-width: 60px; accent-color: #8b5cf6; cursor: pointer;
    height: 3px; -webkit-appearance: none; border-radius: 2px;
    background: rgba(255,255,255,0.15);
}
.tc_color_pick, .tc_stroke_pick {
    width: 26px; height: 22px; border: 1px solid rgba(255,255,255,0.12);
    border-radius: 4px; cursor: pointer; padding: 0; background: none; flex-shrink: 0;
}
.tc_drag_hint {
    font-size: 10px; color: rgba(255,255,255,0.18); margin-left: auto; white-space: nowrap;
}

/* ═══════════════════════════════════════════════════════════════════════════
   ID CARD EDITOR
   ═══════════════════════════════════════════════════════════════════════════ */
.tb_ic_form {
    width: 280px; flex-shrink: 0; padding: 14px 16px; overflow-y: auto;
    border-right: 1px solid rgba(255,255,255,0.06);
}
.tb_ic_slots {
    flex: 1; padding: 14px 16px; overflow-y: auto;
    display: flex; flex-direction: column;
}
.tb_ic_section_title {
    font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
    color: rgba(255,255,255,0.3); margin-bottom: 8px; padding-bottom: 5px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.tb_ic_epoch_row {
    font-size: 11px; color: rgba(255,255,255,0.35); margin-bottom: 10px;
    font-family: monospace;
}
.tb_ic_field_row {
    display: flex; flex-direction: column; gap: 3px; margin-bottom: 7px;
}
.tb_ic_label {
    font-size: 10px; color: rgba(255,255,255,0.35); text-transform: uppercase; letter-spacing: .05em;
}
.tb_ic_input {
    background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1);
    border-radius: 6px; color: rgba(255,255,255,0.9); font-size: 13px;
    padding: 5px 8px; outline: none; font-family: inherit;
}
.tb_ic_input:focus { border-color: rgba(99,102,241,0.5); background: rgba(99,102,241,0.07); }

.tb_ic_yn_row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 4px 0; border-bottom: 1px solid rgba(255,255,255,0.04);
}
.tb_ic_yn_label { font-size: 12px; color: rgba(255,255,255,0.65); }
.tb_ic_yn_btns { display: flex; gap: 5px; }
.tb_ic_yn_btn {
    font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 5px;
    border: 1px solid rgba(255,255,255,0.12); color: rgba(255,255,255,0.35);
    background: transparent; cursor: pointer; transition: all .15s;
}
.tb_ic_yes.tb_ic_yn_active { background: rgba(34,197,94,0.2); color: #22c55e; border-color: rgba(34,197,94,0.4); }
.tb_ic_no.tb_ic_yn_active  { background: rgba(239,68,68,0.2);  color: #ef4444; border-color: rgba(239,68,68,0.4); }
.tb_ic_yn_struck { text-decoration: line-through; opacity: 0.35; }

/* Slot grid */
.tb_ic_slot_grid {
    display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(2, 1fr);
    gap: 6px; flex: 1; min-height: 0;
}
.tb_ic_slot {
    border-radius: 6px; border: 2px dashed rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.02); cursor: pointer;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 4px; transition: all .2s; background-size: cover; background-position: center;
    position: relative; overflow: hidden; min-height: 0;
}
.tb_ic_slot:hover { border-color: rgba(99,102,241,0.5); background: rgba(99,102,241,0.06); }
.tb_ic_slot.tb_ic_slot_filled { border-color: rgba(34,197,94,0.4); }
.tb_ic_slot.tb_ic_slot_drag { border-color: #6366f1 !important; border-style: solid !important; background: rgba(99,102,241,0.15) !important; }
.tb_ic_slot_icon { font-size: 1.1rem; color: rgba(255,255,255,0.2); }
.tb_ic_slot_label { font-size: 9px; color: rgba(255,255,255,0.25); text-align: center; }
