    :root { --bg: #09090b; --pnl: #18181b; --brd: #27272a; --txt: #a1a1aa; --acc: #3b82f6; --grn: #166534; --red: #9f1239; }
    * { box-sizing: border-box; outline: none; -webkit-tap-highlight-color: transparent; }
    input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
    input[type=number] { -moz-appearance: textfield; }
    html { height: 100%; }
    body { background: var(--bg); color: var(--txt); font: 13px/1.4 -apple-system, sans-serif; margin: 0; height: 100%; width: 100%; display: flex; flex-direction: column; overflow: hidden; overscroll-behavior: none; }
    
    /* UTILS & LAYOUT */
    .f-col { display: flex; flex-direction: column; }
    .f-row { display: flex; align-items: center; gap: 8px; }
    .f-grow { flex: 1; min-width: 0; }
    .btn { background: var(--pnl); color: #e4e4e7; border: 1px solid var(--brd); padding: 0 10px; height: 32px; border-radius: 6px; cursor: pointer; display: flex; align-items: center; justify-content: center; white-space: nowrap; user-select: none; transition: 0.1s; font-weight: 500; }
    .btn:active { transform: translateY(1px); } .btn:disabled { opacity: 0.5; cursor: default; }
    .btn-p { background: var(--acc); border-color: var(--acc); color: #fff; }
    .btn-icon { width: 32px; padding: 0; font-size: 16px; }

    /* HUD */
    .hud { height: 50px; height: calc(50px + env(safe-area-inset-top, 0px)); padding: 0 12px; padding: env(safe-area-inset-top, 0px) 12px 0 12px; border-bottom: 1px solid var(--brd); flex-shrink: 0; background: var(--bg); overflow: hidden; }
    .fname { color: #e4e4e7; font-family: monospace; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; width: 100%; }
    .stat { font-family: monospace; color: var(--acc); min-width: 45px; text-align: center; font-size: 12px; flex-shrink: 0; }
    .keys { font-size: 11px; color: #555; display: none; margin-left: 10px; } 
    @media(min-width: 600px) { .keys { display: inline-block; } }

    /* VIDEO PLAYER */
    .vid-box { background: #000; flex: 1; position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden; min-height: 0; }
    video { width: 100%; height: 100%; max-height: 100%; object-fit: contain; }
    
    /* EMPTY STATE */
    #empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 15px; color: #444; }
    #empty h2 { margin: 0; }

    /* EDITOR AREA */
    #editor { border-top: 1px solid var(--brd); background: var(--bg); max-height: 40vh; flex-shrink: 0; display: flex; flex-direction: column; padding-bottom: env(safe-area-inset-bottom, 0px); }
    .row-head { padding: 8px 12px; background: var(--pnl); border-bottom: 1px solid var(--brd); justify-content: space-between; font-weight: 600; color: #fff; display: flex; align-items: center; }
    .list { flex: 1; overflow-y: auto; min-height: 0; padding: 8px; gap: 6px; display: flex; flex-direction: column; }
    .info-lbl { font-size: 11px; color: #666; font-weight: 400; margin-left: 6px; display: none; }
    @media(min-width: 600px) { .info-lbl { display: inline; } }

    /* SEGMENTS */
    .row { background: var(--pnl); padding: 4px; border-radius: 6px; display: flex; flex-direction: row; flex-wrap: nowrap; gap: 4px; align-items: center; overflow: hidden; }
    .row.draft { border: 1px dashed #333; background: rgba(59,130,246,0.05); }
    
    .t-grp { max-width: 30%; display: flex; background: #111; border: 1px solid #333; border-radius: 4px; height: 30px; flex: 10 1 auto; min-width: 0; overflow: hidden; }
    .t-btn { width: 24px; border: none; background: transparent; color: #777; border-right: 1px solid #222; cursor: pointer; display:grid; place-items:center; flex-shrink: 0; }
    .t-btn:hover { background: #222; color: #fff; }
    .t-btn.play { color: #4ade80; }
    .t-btn.set { color: var(--acc); }
    .t-in { background: #111; border: none; color: #8f8; flex: 1; min-width: 0; width: 100%; text-align: center; font-family: monospace; font-size: 11px; padding: 0; }
    
    .name-in { background: #121214; border: 1px solid var(--brd); color: #fff; padding: 0 6px; border-radius: 4px; height: 30px; flex: 15 1 auto; min-width: 40px; font-size: 12px; width: 0; }
    .act-btn { width: 30px; height: 30px; border-radius: 4px; border: none; cursor: pointer; color: #fff; flex-shrink: 0; display:grid; place-items:center;}
    .add { background: var(--grn); } .del { background: transparent; color:#666; } .del:hover { background: var(--red); color:#fff; }

    /* MODALS */
    .overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.85); display: none; align-items: center; justify-content: center; z-index: 50; backdrop-filter: blur(2px); padding: 20px; }
    .modal { background: var(--pnl); border: 1px solid var(--brd); padding: 20px; border-radius: 8px; width: 100%; max-width: 400px; max-height: 80vh; overflow-y: auto; box-shadow: 0 10px 25px rgba(0,0,0,0.5); }
    .modal h3 { margin: 0 0 15px 0; color: #fff; border-bottom: 1px solid var(--brd); padding-bottom: 10px; }
    #md-con table { width: 100%; border-collapse: collapse; margin: 15px 0; font-size: 12px; }
    #md-con th, #md-con td { border: 1px solid var(--brd); padding: 8px; text-align: left; }
    #md-con th { background: #222; color: #fff; }
    #md-con tr:nth-child(even) { background: rgba(255,255,255,0.02); }
    
    .set-row { margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center; }
    .set-row label { color: #e4e4e7; }
    .set-row small { display: block; font-size: 11px; color: #666; margin-top: 2px; }
    .set-row select, .set-row input { background: #09090b; border: 1px solid var(--brd); color: #fff; padding: 6px; border-radius: 4px; }
    
    #log-con { font-family: monospace; color: #aaa; background: #000; padding: 10px; border-radius: 4px; font-size: 11px; white-space: pre-wrap; max-height: 200px; overflow-y: auto; margin-bottom: 15px; }
    #toast { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%); background: var(--acc); color: #fff; padding: 8px 16px; border-radius: 20px; font-weight: 600; opacity: 0; pointer-events: none; transition: 0.3s; z-index: 100; box-shadow: 0 4px 12px rgba(0,0,0,0.3); }
    #toast.show { opacity: 1; bottom: 100px; }