/* Responsive editor refinements. Loaded after style.css. */
html.has-dialog,
html.has-dialog body { overflow: hidden; }

.tl-dialog,
#player-editor:not([hidden]) {
  max-height: min(90dvh, calc(var(--visible-height, 100dvh) - 24px));
  overscroll-behavior: contain;
}

.tl-dialog {
  top: 0;
  bottom: var(--keyboard-inset, 0px);
  margin: auto;
  overscroll-behavior: contain;
}
.tl-dialog .tl-dialog-actions { gap: 10px; }
.tl-dialog-actions .button { min-height: 44px; }

#player-editor:not([hidden]) {
  bottom: calc(var(--keyboard-inset, 0px) + env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
}

.tl-library-tools button,
.tl-library-feedback,
.tl-import-list,
.tl-import-summary,
.tl-import-actions,
.tl-storage-warning { color: var(--ink); }

.tl-library-tools button,
.tl-import-actions button { border-color: var(--line); }
.tl-library-feedback,
.tl-storage-warning { background: var(--soft); border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.tl-import-list { max-height: min(48dvh, 420px); overflow-y: auto; overscroll-behavior: contain; }
.tl-import-list label { display: flex; align-items: flex-start; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.tl-import-list input[type="checkbox"] { flex: 0 0 20px; width: 20px; height: 20px; min-width: 20px; margin: 2px 0 0; padding: 0; accent-color: var(--accent); }
.tl-import-detail { min-width: 0; }
.tl-import-detail h3 { margin: 0 0 4px; overflow-wrap: anywhere; }
.tl-import-detail p { margin: 0; color: var(--muted); }
.tl-import-actions { position: sticky; bottom: -20px; z-index: 1; background: var(--panel); padding: 12px 0 max(12px, env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); }

@media (max-width: 650px) {
  input:not([type="checkbox"]), select { font-size: 16px; }
  .share-panel > select,
  .formation-picker select,
  #export-style { font-size: 16px; }

  #mobile-menu,
  .saved-nav,
  .theme-toggle,
  .pitch-toolbar button,
  .history-tools .icon-button,
  .tl-dialog-header button,
  .tl-library-tools button,
  .tl-library-actions button,
  .tl-dialog-actions .button { min-width: 44px; min-height: 44px; }

  #mobile-menu { display: grid; place-items: center; padding: 0; flex: 0 0 44px; }
  .saved-nav { display: grid; place-items: center; padding: 0; flex: 0 0 44px; }
  .theme-toggle { height: 44px; min-width: 54px; padding: 8px; margin: 0; }
  .theme-toggle > span { width: 24px; height: 24px; }
  .header-inner { gap: 8px; }
  .brand { min-width: 0; font-size: 16px; gap: 5px; }
  .brand-mark { flex: 0 0 25px; }

  .formation-chips button { min-height: 44px; height: auto; }
  .pitch-toolbar { height: auto; min-height: 44px; }
  .pitch-toolbar button,
  .history-tools .icon-button { width: 44px; height: 44px; }

  #player-editor:not([hidden]) {
    top: auto;
    bottom: calc(var(--keyboard-inset, 0px) + env(safe-area-inset-bottom, 0px));
    max-height: calc(var(--visible-height, 100dvh) - 24px);
  }
  .tl-dialog { max-height: min(90dvh, calc(var(--visible-height, 100dvh) - 24px)); }
  .tl-dialog[open] { margin: auto; }
  .tl-dialog-actions { position: sticky; bottom: -20px; z-index: 1; background: var(--panel); padding: 12px 0 max(12px, env(safe-area-inset-bottom, 0px)); }
  .tl-dialog-actions .button { flex: 1 1 130px; }
  .tl-import-list { max-height: calc(var(--visible-height, 100dvh) * .42); }
}

@media (max-width: 650px) and (orientation: landscape) and (max-height: 500px) {
  #player-editor:not([hidden]),
  .tl-dialog { max-height: calc(var(--visible-height, 100dvh) - 16px); }
}

.tl-library-tools{display:flex;gap:10px;flex-wrap:wrap}.tl-library-tools .button{flex:1}.tl-library-help{font-size:12px;line-height:1.7;color:var(--muted)}.tl-library-feedback:empty{display:none}.tl-library-feedback{font-size:12px;line-height:1.6;overflow-wrap:anywhere}.tl-import-summary{font-size:13px}.tl-import-detail strong,.tl-import-detail small{display:block;overflow-wrap:anywhere}.tl-import-detail strong{font-size:14px;line-height:1.4}.tl-import-detail small{font-size:11px;color:var(--muted);margin-top:4px}.tl-import-row{cursor:pointer}.player-edit-actions{display:flex;gap:7px;margin-top:14px}.player-edit-actions .button{flex:1;font-size:11px;padding:8px 6px;min-height:40px}.tl-storage-warning{font-size:13px;margin:0 0 16px}.tl-storage-warning button{background:none;padding:0 4px;display:inline;text-decoration:underline}.tl-inline-feedback{font-size:12px;line-height:1.6;color:var(--muted)}.tl-inline-feedback:empty{display:none}.button-primary{background:var(--accent);color:var(--accent-ink);border-color:var(--accent)}
@media(max-width:650px){.tl-saved-actions .button,.player-edit-actions .button{min-height:44px}.tl-dialog input:not([type="checkbox"]),#player-editor input{font-size:16px}.share-panel>select{height:44px;padding:8px 6px}.formation-picker select{width:92px;height:44px}.eleven-tag{font-size:6px;padding-left:5px}.history-tools{gap:0}.player-edit-actions{position:sticky;bottom:-20px;padding:12px 0 0;background:var(--panel)}#player-editor:not([hidden]){bottom:calc(var(--keyboard-inset,0px) + max(12px,env(safe-area-inset-bottom,0px)))}.tl-toast{bottom:calc(var(--keyboard-inset,0px) + 16px);font-size:12px}.tl-dialog .tl-dialog-intro{margin:12px 0 18px}}

@media(max-width:360px){.eleven-tag{display:none}.header-inner{gap:5px}.brand{font-size:15px}.theme-toggle{padding:4px;min-width:52px}.formation-picker select{width:86px}}
@media(max-width:1000px) and (max-height:500px){#player-editor:not([hidden]){position:fixed;left:auto;right:12px;top:auto;bottom:calc(var(--keyboard-inset,0px) + max(8px,env(safe-area-inset-bottom,0px)));z-index:70;width:min(390px,calc(100vw - 24px));max-height:calc(var(--visible-height,100dvh) - 16px);padding:16px 20px;background:var(--panel);border:1px solid var(--line);border-radius:12px;box-shadow:0 6px 50px #0003}#player-editor input{font-size:16px;min-height:40px}#player-editor>.field-hint{display:none}.player-edit-actions .button{min-height:44px}.player-fields{grid-template-columns:1fr 1fr}}
