/* Python Tkinter Lab — ilova va «Tk oynasi» ko'rinishi */
:root {
  --bg: #0f172a; --panel: #111c33; --panel2: #16233f; --line: #24324f; --text: #e2e8f0; --muted: #94a3b8;
  --acc: #ffd43b; --acc2: #3776ab; --ok: #22c55e; --bad: #f87171; --code-bg: #0b1220;
  --mono: "JetBrains Mono", Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 "Golos Text", system-ui, sans-serif; }
button { font: inherit; }
a { color: #93c5fd; }
.tl-boot { padding: 40px; color: var(--muted); }
#app { display: flex; flex-direction: column; height: 100vh; }

/* ---------- yuqori panel ---------- */
.tl-top { display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: #0b1324; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tl-back { color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line); }
.tl-back:hover { color: var(--text); }
.tl-logo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; }
.tl-logo b { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, var(--acc2), var(--acc)); color: #0b1324; font-size: 15px; }
.tl-tabs { display: flex; gap: 4px; margin-left: 12px; }
.tl-tab { background: none; border: 0; color: var(--muted); padding: 7px 12px; border-radius: 8px; cursor: pointer; }
.tl-tab.on, .tl-tab:hover { background: var(--panel2); color: var(--text); }
.tl-sp { flex: 1; }
.tl-lang { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.tl-lang button { background: none; border: 0; color: var(--muted); padding: 5px 9px; cursor: pointer; }
.tl-lang button.on { background: var(--panel2); color: var(--text); }
.tl-user { color: var(--muted); font-size: 13px; }

/* ---------- loyihalar ro'yxati ---------- */
.tl-home { overflow: auto; flex: 1; padding: 22px clamp(14px, 3vw, 40px) 60px; }
.tl-hero { max-width: 1100px; margin: 0 auto 18px; }
.tl-hero h1 { margin: 0 0 6px; font-size: clamp(22px, 3vw, 30px); }
.tl-hero p { margin: 0; color: var(--muted); max-width: 760px; }
.tl-load { margin-top: 10px; color: var(--muted); font-size: 13px; }
.tl-grid { max-width: 1100px; margin: 0 auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.tl-card { position: relative; text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; color: var(--text); cursor: pointer; display: flex; flex-direction: column; gap: 8px; transition: transform .15s, border-color .15s; }
.tl-card:hover { transform: translateY(-2px); border-color: #3b4f78; }
.tl-card .ico { font-size: 28px; line-height: 1; }
.tl-card h3 { margin: 0; font-size: 16px; }
.tl-card .no { position: absolute; right: 14px; top: 14px; color: var(--muted); font: 600 12px var(--mono); }
.tl-card p { margin: 0; color: var(--muted); font-size: 13px; flex: 1; }
.tl-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.tl-chip { font: 11px var(--mono); padding: 2px 6px; border-radius: 6px; background: #1d2b4a; color: #bfdbfe; }
.tl-bar { height: 5px; background: #1d2b4a; border-radius: 4px; overflow: hidden; }
.tl-bar i { display: block; height: 100%; background: var(--ok); }
.tl-card.done { border-color: #166534; }
.tl-card.done::after { content: "✓"; position: absolute; right: 12px; bottom: 10px; color: var(--ok); font-weight: 700; }
.tl-lvl { font-size: 11px; color: var(--muted); }
.tl-sec { max-width: 1100px; margin: 26px auto 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }

/* ---------- ish maydoni ---------- */
.tl-work { flex: 1; display: grid; grid-template-columns: minmax(280px, 360px) minmax(320px, 1fr) minmax(320px, 1fr); min-height: 0; }
.tl-side { border-right: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
.tl-side-head { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.tl-side-head h2 { margin: 0; font-size: 16px; display: flex; gap: 8px; align-items: center; }
.tl-steps { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 8px; }
.tl-steps button { width: 28px; height: 28px; border-radius: 7px; border: 1px solid var(--line); background: var(--panel2); color: var(--muted); cursor: pointer; font: 600 12px var(--mono); }
.tl-steps button.cur { border-color: var(--acc); color: var(--acc); }
.tl-steps button.done { background: #14532d; color: #bbf7d0; border-color: #166534; }
.tl-steps button:disabled { opacity: .45; cursor: not-allowed; }
.tl-task { padding: 14px; overflow: auto; flex: 1; }
.tl-task h3 { margin: 0 0 8px; font-size: 15px; }
.tl-md p { margin: 0 0 10px; }
.tl-md ul { margin: 0 0 10px; padding-left: 20px; }
.tl-md code { font: 12.5px var(--mono); background: #0b1220; padding: 1px 5px; border-radius: 5px; color: #fde68a; }
.tl-md pre { background: var(--code-bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px; overflow: auto; font: 12.5px/1.5 var(--mono); margin: 0 0 10px; }
.tl-md pre code { background: none; padding: 0; color: #e2e8f0; }
.tl-md .tip { background: #172554; border-left: 3px solid #60a5fa; padding: 8px 10px; border-radius: 6px; margin: 0 0 10px; font-size: 13px; }
.tl-actions { display: flex; gap: 6px; flex-wrap: wrap; padding: 10px 14px; border-top: 1px solid var(--line); }
.btn { border: 1px solid var(--line); background: var(--panel2); color: var(--text); padding: 7px 12px; border-radius: 8px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.btn:hover { border-color: #3b4f78; }
.btn.pri { background: var(--acc); color: #1e293b; border-color: var(--acc); font-weight: 600; }
.btn.go { background: #16a34a; border-color: #16a34a; color: #fff; font-weight: 600; }
.btn:disabled { opacity: .5; cursor: wait; }
.tl-res { margin: 10px 0 0; padding: 10px 12px; border-radius: 8px; font-size: 13px; }
.tl-res.ok { background: #052e16; border: 1px solid #166534; color: #bbf7d0; }
.tl-res.bad { background: #2a0f12; border: 1px solid #7f1d1d; color: #fecaca; }
.tl-res.info { background: #172554; border: 1px solid #1e3a8a; color: #bfdbfe; }
.tl-hint { margin-top: 10px; padding: 10px 12px; border-radius: 8px; background: #1f1a07; border: 1px solid #713f12; color: #fde68a; font-size: 13px; }
.tl-hint pre { margin: 8px 0 0; }

/* muharrir */
.tl-mid { display: flex; flex-direction: column; min-width: 0; min-height: 0; border-right: 1px solid var(--line); }
.tl-tools { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--line); background: #0d1730; flex-wrap: wrap; }
.tl-file { font: 12.5px var(--mono); color: var(--muted); margin-right: auto; display: flex; align-items: center; gap: 6px; }
.tl-file input { background: transparent; border: 1px solid transparent; color: var(--text); font: inherit; padding: 2px 4px; border-radius: 5px; width: 170px; }
.tl-file input:hover, .tl-file input:focus { border-color: var(--line); outline: 0; }
.ed { position: relative; flex: 1; overflow: auto; background: var(--code-bg); display: flex; align-items: flex-start; }
/* Ustun va kod qatlami matn bo'yicha o'sadi (stretch bilan oyna balandligida qotib, pastki qatorlar kesilardi) */
.ed-gut, .ed-wrap { min-height: 100%; }
.ed-gut { padding: 12px 8px 12px 12px; text-align: right; color: #475569; font: 13px/1.6 var(--mono); user-select: none; white-space: pre; min-width: 42px; }
.ed-wrap { position: relative; flex: 1 0 auto; min-width: 0; }
.ed-hl, .ed-in { margin: 0; padding: 12px 14px 40px 6px; font: 13px/1.6 var(--mono); white-space: pre; tab-size: 4; border: 0; min-height: 100%; }
.ed-hl { position: absolute; inset: 0; pointer-events: none; color: #e2e8f0; overflow: hidden; }
.ed-in { position: relative; width: 100%; resize: none; background: transparent; color: transparent; caret-color: #fde68a; outline: 0; overflow: hidden; display: block; }
.ed-in::selection { background: rgba(96, 165, 250, .35); }
.ed .err-line { position: absolute; left: 0; right: 0; height: 1.6em; background: rgba(248, 113, 113, .16); pointer-events: none; }
.tok-kw { color: #c084fc; } .tok-str { color: #86efac; } .tok-num { color: #fdba74; } .tok-com { color: #64748b; font-style: italic; }
.tok-fn { color: #7dd3fc; } .tok-bi { color: #fde68a; } .tok-op { color: #e2e8f0; } .tok-dec { color: #f472b6; }

/* sahna va konsol */
.tl-right { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.tl-stage-head, .tl-con-head { display: flex; align-items: center; gap: 8px; padding: 6px 10px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line); background: #0d1730; }
.tl-stage-head b, .tl-con-head b { color: var(--text); font-weight: 600; }
.tl-stage { position: relative; flex: 1; min-height: 260px; overflow: auto; background: #1e2a44 radial-gradient(#2b3a5c 1px, transparent 1px) 0 0 / 18px 18px; }
.tl-stage-empty[hidden] { display: none; }
.tl-stage-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); text-align: center; padding: 20px; font-size: 13px; pointer-events: none; }
.tl-con { height: 30%; min-height: 110px; display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.tl-con-out { flex: 1; overflow: auto; margin: 0; padding: 8px 10px; font: 12.5px/1.5 var(--mono); background: #0a0f1c; white-space: pre-wrap; word-break: break-word; }
.tl-con-out .err { color: #fca5a5; }
.tl-con-out .sys { color: #64748b; }
.tl-con-out .tip { color: #fde68a; }
.tl-con-head button { margin-left: auto; background: none; border: 0; color: var(--muted); cursor: pointer; }

/* erkin rejim */
.tl-free-list { padding: 12px; overflow: auto; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.tl-free-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel2); cursor: pointer; }
.tl-free-item.cur { border-color: var(--acc); }
.tl-free-item span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-free-item small { color: var(--muted); }
.tl-free-item i { color: var(--muted); font-style: normal; padding: 0 4px; }
.tl-free-item i:hover { color: var(--bad); }
.tl-tpl { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 0 12px 12px; }
.tl-tpl button { font-size: 12px; text-align: left; }

/* ma'lumotnoma */
.tl-ref { flex: 1; overflow: auto; padding: 22px clamp(14px, 3vw, 40px) 60px; }
.tl-ref-grid { max-width: 1100px; margin: 0 auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.tl-ref-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.tl-ref-card h3 { margin: 0 0 6px; font: 600 14px var(--mono); color: var(--acc); }

/* yakun oynasi */
.tl-modal-ov { position: fixed; inset: 0; background: rgba(2, 6, 23, .7); display: grid; place-items: center; z-index: 1000; padding: 16px; }
.tl-modal { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 22px; max-width: 560px; width: 100%; max-height: 90vh; overflow: auto; }
.tl-modal h2 { margin: 0 0 8px; }
.tl-modal .row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.tl-toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #052e16; border: 1px solid #166534; color: #bbf7d0; padding: 10px 16px; border-radius: 10px; z-index: 1100; }

@media (max-width: 1100px) {
  .tl-work { grid-template-columns: 1fr 1fr; grid-template-rows: auto 1fr; }
  .tl-side { grid-column: 1 / -1; max-height: 42vh; border-right: 0; border-bottom: 1px solid var(--line); }
}
@media (max-width: 720px) {
  #app { height: auto; min-height: 100vh; }
  .tl-work { display: flex; flex-direction: column; }
  .tl-side { max-height: none; }
  .ed { min-height: 320px; }
  .tl-stage { min-height: 360px; }
  .tl-tabs { margin-left: 0; order: 5; width: 100%; }
}

/* =================== Tk oynasi (Windows 10 uslubida) =================== */
.tkw { position: absolute; background: #fff; border: 1px solid #1883d7; box-shadow: 0 8px 30px rgba(0, 0, 0, .45); color: #000; font: 12px "Segoe UI", Tahoma, system-ui, sans-serif; min-width: 140px; display: flex; flex-direction: column; outline: 0; }
.tkw-bar { display: flex; align-items: center; height: 30px; background: #fff; user-select: none; cursor: default; }
.tkw:focus-within .tkw-bar, .tkw:focus .tkw-bar { background: #fff; }
.tkw-ico { width: 16px; height: 16px; margin: 0 8px 0 8px; background: linear-gradient(135deg, #3776ab 50%, #ffd43b 50%); border-radius: 3px; flex: none; }
.tkw-title { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
.tkw-btns { display: flex; height: 100%; }
.tkw-btns i { width: 44px; display: grid; place-items: center; font-style: normal; font-size: 12px; color: #111; }
.tkw-btns i:hover { background: #e5e5e5; }
.tkw-btns i.tkw-x:hover { background: #e81123; color: #fff; }
.tkw.noresize .tkw-max { color: #bbb; pointer-events: none; }
.tkw-menu { display: flex; background: #fff; border-bottom: 1px solid #f0f0f0; padding: 0 2px; }
.tkm-top { padding: 3px 8px; cursor: default; }
.tkm-top:hover, .tkm-top.open { background: #cce8ff; }
.tkm-drop { position: absolute; z-index: 50; background: #f2f2f2; border: 1px solid #ccc; box-shadow: 2px 2px 6px rgba(0, 0, 0, .25); padding: 2px 0; min-width: 170px; }
.tkm-drop hr { border: 0; border-top: 1px solid #d7d7d7; margin: 3px 2px 3px 28px; }
.tkm-item { position: relative; display: flex; align-items: center; padding: 3px 10px 3px 0; cursor: default; white-space: nowrap; }
.tkm-item:hover { background: #91c9f7; }
.tkm-item.disabled { color: #999; }
.tkm-chk { width: 26px; text-align: center; }
.tkm-l { flex: 1; }
.tkm-a { color: #666; margin-left: 24px; }
.tkm-sub { margin-left: 10px; }
.tkw-body { position: relative; background: #f0f0f0; min-width: 120px; min-height: 30px; overflow: hidden; display: flex; flex-direction: column; }
.tkw-body.tk-empty { width: 200px; height: 200px; }
.tkw.fixed .tkw-body { flex: none; }
.tkw.min .tkw-body, .tkw.min .tkw-menu { display: none; }
.tkw.max { left: 0 !important; top: 0 !important; right: 0; bottom: 0; }
.tkw.max .tkw-body { width: auto !important; height: auto !important; flex: 1; }
.tkw[hidden] { display: none; }

/* idishlar */
.tk-c { position: relative; }
.tk-gridbox { display: grid !important; }
.tk-packbox { display: flex !important; flex-direction: column; }
.tkw-body.tk-packbox, .tkw-body.tk-gridbox { flex: 1 1 auto; }
.tk-frame { background: #f0f0f0; display: flex; flex-direction: column; }
.tk-frame.sized.tk-packbox, .tk-frame.sized.tk-gridbox { overflow: hidden; }
.tk-frame.noprop { overflow: hidden; }
.tk-lframe { margin: 0; padding: 4px 6px 6px; border: 1px solid #d5dfe5; border-radius: 0; background: #f0f0f0; min-width: 0; display: flex; flex-direction: column; }
.tk-lframe legend { padding: 0 3px; font: inherit; }
.tk-pk { display: flex; min-width: 0; min-height: 0; }
.tk-pk-cav { flex: 1 1 auto; }
.tk-pk-cav.v { flex-direction: column; }
.tk-pk-cav.h { flex-direction: row; }
.tk-pk-cav.last:empty { flex: 1 1 0; }
.tk-pk-cav.noexp, .tk-pk-cav.noexp.last:empty { flex: 0 1 0; }
.tk-pk-parcel { flex: 0 0 auto; min-width: auto; min-height: auto; }
.tk-pk-parcel.v { flex-direction: column; }
.tk-pk-parcel.h { flex-direction: row; }
.tk-pk-cav.v > .tk-pk-parcel { align-self: stretch; }
.tk-pk-cav.h > .tk-pk-parcel { align-self: stretch; }
.tk-pk-parcel.v { align-items: center; }
.tk-pk-parcel.h { align-items: center; }
.tk-has-place { position: relative; }
.fill-x { width: auto !important; }
.fill-y { height: auto !important; }

/* vidjetlar */
.tk-label { display: flex; align-items: center; justify-content: center; text-align: center; white-space: pre; padding: 1px; background: transparent; min-height: 1.4em; }
.tk-label[style*="max-width"] { white-space: pre-wrap; }
.tk-button { font: inherit; display: flex; align-items: center; justify-content: center; text-align: center; white-space: pre; padding: 2px 8px; min-height: 24px; background: #e1e1e1; border: 1px solid #adadad; color: #000; cursor: default; border-radius: 0; }
.tk-button:hover { background: #e5f1fb; border-color: #0078d7; }
.tk-button:active { background: var(--tk-abg, #cce4f7); color: var(--tk-afg, inherit); border-color: #005499; }
.tk-button[style*="background-color"]:hover { filter: brightness(1.08); }
.tk-button:disabled { color: #838383; background: #ccc; border-color: #bfbfbf; filter: none; }
.tk-entry { display: flex; background: #fff; border: 1px solid #7a7a7a; min-width: 30px; position: relative; }
.tk-entry:focus-within { border-color: #0078d7; }
.tk-entry input { flex: 1; min-width: 0; border: 0; outline: 0; font: inherit; padding: 2px 3px; background: transparent; color: inherit; }
.tk-entry.disabled { background: #f0f0f0; color: #6d6d6d; }
.tk-spin { display: flex; flex-direction: column; border-left: 1px solid #ccc; font-size: 7px; user-select: none; }
.tk-spin i { flex: 1; font-style: normal; padding: 0 3px; display: grid; place-items: center; background: #f0f0f0; cursor: default; }
.tk-spin i:hover { background: #e5f1fb; }
.tk-combobox select { position: absolute; inset: 0; opacity: 0; display: none; }
.tk-combobox.ro select { display: block; cursor: default; }
.tk-combobox::after { content: "⌄"; padding: 0 5px; display: grid; place-items: center; border-left: 1px solid #ddd; pointer-events: none; }
.tk-optionmenu select { font: inherit; padding: 3px 6px; background: #e1e1e1; border: 1px solid #adadad; border-radius: 0; min-width: 60px; }
.tk-text { display: flex; background: #fff; border: 1px solid #7a7a7a; }
.tk-text textarea { flex: 1; resize: none; border: 0; outline: 0; font: 13px Consolas, "Courier New", monospace; padding: 2px 4px; background: transparent; color: inherit; }
.tk-listbox { position: relative; background: #fff; border: 1px solid #7a7a7a; outline: 0; cursor: default; user-select: none; }
.tk-lb-in { position: absolute; inset: 0; overflow: auto; }
.tk-li { padding: 0 3px; white-space: pre; line-height: 1.25em; }
.tk-li.sel { background: var(--tk-sbg, #0078d7) !important; color: #fff !important; }
.tk-scrollbar { width: 17px; min-height: 40px; background: #f0f0f0; border-left: 1px solid #e3e3e3; align-self: stretch; }
.tk-canvas { position: relative; background: #f0f0f0; overflow: hidden; touch-action: none; }
.tk-canvas svg { display: block; }
.tk-scale { display: flex; flex-direction: column; align-items: stretch; padding: 2px; gap: 1px; }
.tk-scale-lbl:empty { display: none; }
.tk-scale-val { text-align: center; font-size: 12px; min-height: 1.2em; }
.tk-scale input { accent-color: #0078d7; }
.tk-scale.vert { flex-direction: row; align-items: center; }
.tk-scale.vert input { writing-mode: vertical-lr; direction: ltr; }
.tk-scale.vert input.rev, .tk-scale input.rev { direction: rtl; }
.tk-check { display: inline-flex; align-items: center; gap: 4px; padding: 1px 2px; cursor: default; white-space: pre; }
.tk-check input { margin: 0; accent-color: #0078d7; }
.tk-progress { width: 100px; height: 18px; background: #e6e6e6; border: 1px solid #bcbcbc; }
.tk-progress span { display: block; height: 100%; background: #06b025; width: 0; transition: width .15s; }
.tk-sep { height: 1px; background: #c8c8c8; align-self: stretch; margin: 2px 0; }
.tk-sep.v { width: 1px; height: auto; }
.disabled { color: #838383; }

/* messagebox */
.tk-msg-ov { position: absolute; inset: 0; background: rgba(0, 0, 0, .15); display: grid; place-items: center; z-index: 9999; }
.tk-msg { background: #fff; border: 1px solid #1883d7; box-shadow: 0 8px 30px rgba(0, 0, 0, .4); color: #000; font: 12px "Segoe UI", Tahoma, system-ui, sans-serif; min-width: 260px; max-width: 420px; }
.tk-msg-body { display: flex; gap: 12px; align-items: center; padding: 22px 18px; }
.tk-msg-ico { width: 32px; height: 32px; border-radius: 50%; flex: none; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 18px; }
.tk-msg.showinfo .tk-msg-ico { background: #0063b1; } .tk-msg.showinfo .tk-msg-ico::after { content: "i"; }
.tk-msg.showwarning .tk-msg-ico { background: #ffb900; color: #000; border-radius: 4px; } .tk-msg.showwarning .tk-msg-ico::after { content: "!"; }
.tk-msg.showerror .tk-msg-ico { background: #e81123; } .tk-msg.showerror .tk-msg-ico::after { content: "✕"; }
.tk-msg-txt { white-space: pre-wrap; }
.tk-msg-foot { background: #f0f0f0; padding: 10px 12px; display: flex; justify-content: flex-end; }
.tk-msg-foot .tk-button { min-width: 74px; }
.tl-modal .tl-md pre { white-space: pre-wrap; }
