/* Shared material and controls for planner, account pages and administration. */
:root {
  color-scheme: dark;
  --accent: #c7a76b;
  --accent-lit: #e1c58e;
  --weave: url('../img/ui-weave.svg?v=20260911-3');
  --weave-size: 160px 160px;
  --weave-pos: 0 0;
}
.ui-icon {
  display: inline-block; width: 17px; height: 17px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px;
  pointer-events: none;
}
.ui-icon * { pointer-events: none; }
.btn .ui-icon { margin-inline: 1px 3px; }
.modal-close .ui-icon, .account a .ui-icon { margin: 0; }
.modal-close .ui-icon { width: 15px; height: 15px; }
.modal { background-color: rgba(4,6,7,.74); backdrop-filter: blur(5px); }
.modal-body, .chat-dock, #topbar .more-menu {
  background-color: #191d1f;
  background-image: var(--weave); background-size: var(--weave-size);
  background-position: 0 0;
  border-color: rgba(199,167,107,.3);
  box-shadow: 0 24px 70px rgba(0,0,0,.55), inset 0 1px 0 rgba(225,197,142,.08);
}
.modal-body { border-radius: 12px; }
.modal-body > h2 {
  font-size: 17px; font-weight: 600; color: var(--accent-lit);
  padding-right: 48px; line-height: 1.5;
  background: linear-gradient(100deg, rgba(199,167,107,.07), transparent), #1d2224;
}
.modal-body > h2 .ui-icon { margin-right: 7px; }
.modal-body .btn, .chat-dock .btn { border-radius: 6px; min-height: 34px; }
.modal-body input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="range"]):not([type="file"]),
.modal-body select, .modal-body textarea {
  background-color: #131719; border: 1px solid #394140;
  border-radius: 6px; padding: 9px 11px; color: #e2e3df;
}
.modal-body input:focus-visible, .modal-body select:focus-visible, .modal-body textarea:focus-visible {
  border-color: var(--accent); outline: 2px solid rgba(199,167,107,.5); outline-offset: 2px;
}
.modal-body .muted, .profile-hint { color: #a5aaa9; }
#profileModal .modal-body { width: min(94vw, 780px); }
.profile-preview {
  gap: 16px; padding: 20px; border-radius: 9px;
  border: 1px solid rgba(199,167,107,.25);
  background: radial-gradient(ellipse at top left, rgba(199,167,107,.09), transparent 75%), #121719;
}
.profile-preview .nick { font-size: 23px; line-height: 1.4; overflow-wrap: anywhere; }
.profile-preview > div { min-width: 0; }
.profile-preview .who-login { font-size: 12px; margin-top: 5px; }
.profile-section {
  margin-top: 16px; padding: 16px;
  border: 1px solid rgba(199,167,107,.13); border-radius: 8px;
  background: rgba(13,17,18,.42);
}
.profile-section > h3 {
  margin: 0 0 12px; font-size: 10px; font-weight: 600;
  letter-spacing: 1.5px; color: var(--accent-lit);
}
.profile-hint { font-size: 12px; line-height: 1.65; margin-top: 10px; }
.av-picker { display: flex; gap: 8px; margin-bottom: 12px; }
.av-emojis { display: flex; flex-wrap: wrap; gap: 7px; }
.av-emojis button { width: 36px; height: 36px; border-radius: 7px; background: #202628; }
.av-emojis button.on, .fx-option.on {
  border-color: var(--accent);
  background: linear-gradient(135deg, rgba(199,167,107,.14), rgba(199,167,107,.04)), #1b2021;
  box-shadow: inset 0 1px 0 rgba(225,197,142,.13);
}
.swatches { gap: 9px; padding: 3px; margin-bottom: 12px; }
.swatches .swatch { width: 25px; height: 25px; }
.swatches .swatch.on { outline: 2px solid var(--accent-lit); outline-offset: 3px; box-shadow: none; }
.fx-grid { grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); gap: 8px; }
.fx-option { min-height: 76px; gap: 6px; padding: 12px; border-radius: 7px; background: #202628; }
.fx-option .fx-note { font-size: 11px; line-height: 1.5; }
.profile-actions { padding: 5px 0; gap: 12px; flex-wrap: wrap; }
#profileSave { min-height: 40px; padding-inline: 18px; font-weight: 600; }
.profile-section.danger-zone { border-color: rgba(201,88,79,.25); background: rgba(65,23,21,.12); }
.danger-zone > h3 { color: #e08e83; }
.danger-zone .btn.danger { color: #eea093; }
#topbar .more-menu > .btn, #topbar .more-menu > .field,
#topbar .more-menu > .edit-menu > .btn {
  background: #22282a; border-color: rgba(199,167,107,.1);
  border-radius: 7px; min-height: 40px;
}
#topbar .more-menu .account { padding: 12px 9px; gap: 9px; }
#topbar .more-menu .account a { width: 30px; height: 30px; color: #b9bcb6; }
#topbar .more-menu .account a:hover { color: var(--accent-lit); background: rgba(199,167,107,.1); }
.chat-head, .global-head { background: linear-gradient(90deg, rgba(199,167,107,.07), transparent), #1d2224; }
.chat-thread, .chat-people { background-image: var(--weave); background-size: var(--weave-size); }
.admin-page .wrap { max-width: 1100px; padding: 24px; }
.admin-page .user { padding: 14px; margin-bottom: 7px; border-radius: 8px; border: 1px solid rgba(199,167,107,.15); background: #1b2022; }
.admin-page .group { margin-block: 22px; }
.admin-page .head { padding-bottom: 16px; border-bottom: 1px solid rgba(199,167,107,.2); }
@media (max-width: 560px) {
  #profileModal .modal-body { padding: 16px; }
  #profileModal .modal-body > h2 { margin: -16px -16px 16px; padding: 14px 48px 14px 16px; }
  .profile-section { padding: 12px; }
  .profile-preview { padding: 16px; }
  .profile-preview .nick { font-size: 19px; }
  .fx-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fx-option { padding: 10px; }
  .profile-row { gap: 10px; }
  .profile-row input[type="password"] { flex-basis: 100%; }
  .modal-body .btn { min-height: 38px; }
  .admin-page .wrap { padding: 14px; }
}

/* Conversation surfaces: readable messages on a quiet, shared material. */
.chat-head { min-height: 46px; padding: 10px 12px; gap: 9px; }
.chat-title { font-size: 11px; letter-spacing: 1.2px; color: var(--accent-lit); }
.chat-title .nick { letter-spacing: normal; font-size: 13px; }
.chat-head .chat-min, .chat-head .chat-x, .chat-head .chat-back { width: 28px; height: 28px; }
.chat-thread, .global-thread {
  padding: 14px 12px; scrollbar-gutter: stable; overscroll-behavior: contain;
  background-color: #131819; background-image: var(--weave); background-size: var(--weave-size);
}
.global-msg {
  display: grid; grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: 'author time' 'message message';
  column-gap: 10px; row-gap: 6px; padding: 11px 12px;
  margin-bottom: 9px; border: 1px solid #2b3334; border-radius: 9px;
  background: #1c2224; line-height: 1.6;
}
.global-msg:hover { background: #202729; border-color: #41443b; }
.global-msg.mine {
  background: linear-gradient(110deg, rgba(199,167,107,.07), transparent), #1c2224;
  border-color: rgba(199,167,107,.28); box-shadow: inset 2px 0 0 var(--accent-dim);
}
.global-who { grid-area: author; margin: 0; min-width: 0; align-self: center; }
.global-who .nick-wrap { display: flex; min-width: 0; gap: 7px; }
.global-who .nick { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.global-text { grid-area: message; display: block; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; color: #e2e5e1; }
.global-msg time { grid-area: time; align-self: center; margin: 0; font-size: 10px; color: #9da8a6; white-space: nowrap; font-variant-numeric: tabular-nums; }
.global-msg:has(.global-drop) time { padding-right: 20px; }
.global-drop { top: 10px; right: 7px; width: 23px; height: 23px; display: grid; place-items: center; border-radius: 5px; padding: 0; }
.global-drop .ui-icon { width: 13px; height: 13px; }
.global-msg:focus-within .global-drop { opacity: 1; }
.global-drop:hover { background: rgba(201,88,79,.14); }
.chat-thread { gap: 12px; }
.chat-msg { max-width: 88%; min-width: 0; flex: none; }
.chat-bubble {
  padding: 10px 12px; border-radius: 11px 11px 11px 3px;
  background: #222a2d; border-color: #343e40; color: #e2e5e1; line-height: 1.65;
  box-shadow: 0 2px 5px rgba(0,0,0,.12);
}
.chat-msg.mine .chat-bubble {
  background: linear-gradient(135deg, rgba(199,167,107,.12), rgba(199,167,107,.045)), #232722;
  border-color: rgba(199,167,107,.34); border-radius: 11px 11px 3px 11px;
}
.chat-msg time { margin: 5px 3px 0; color: #9da8a6; font-variant-numeric: tabular-nums; }
.chat-seen { margin: 4px 3px; }
.chat-photo { border-radius: 10px; border-color: #414940; }
.chat-tabs { gap: 5px; padding: 8px; border-bottom: 1px solid var(--edge-soft); background: #191f21; }
.chat-tab { min-height: 34px; border: 1px solid transparent; border-radius: 6px; padding: 7px; }
.chat-tab.on { background: rgba(199,167,107,.1); border-color: rgba(199,167,107,.3); color: var(--accent-lit); }
.chat-people { padding: 9px; gap: 6px; background-color: #131819; }
.chat-person { min-height: 51px; padding: 11px; gap: 10px; border: 1px solid #2a3335; border-radius: 8px; background: #1c2325; }
.chat-person:hover, .chat-person.on { border-color: var(--accent-dim); background: #252d2d; }
.chat-person .nick-wrap { min-width: 0; }
.chat-person .nick { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-person.has-unread { border-left: 3px solid var(--accent); background: #252a24; }
.chat-dot { background: var(--accent); color: #171b17; box-shadow: 0 0 0 2px #1b2223; }
.friend-row { padding: 11px; margin-bottom: 6px; border: 1px solid #2c3536; background: #1c2325; gap: 10px; flex-wrap: wrap; }
.friend-acts { margin-left: auto; }
.friend-acts button { min-height: 29px; border-radius: 5px; }
.friend-head { padding: 14px 4px 8px; color: var(--accent-lit); font-size: 10px; letter-spacing: 1px; }
.chat-form, .global-form { padding: 11px; gap: 8px; background: #1b2123; border-top: 1px solid var(--edge); }
.chat-form textarea, .global-form textarea {
  min-height: 40px; padding: 10px 11px; border-radius: 8px;
  background: #101617; border: 1px solid #414a47; line-height: 1.5;
}
.chat-form textarea::placeholder, .global-form textarea::placeholder { color: #949e9b; opacity: 1; }
.chat-form textarea:focus, .global-form textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(199,167,107,.1); }
.chat-go, .global-go, .chat-clip { width: 40px; height: 40px; border-radius: 8px; }
.chat-go, .global-go { background: var(--accent); border-color: var(--accent); color: #171c19; }
.chat-go:hover, .global-go:hover { background: var(--accent-lit); color: #111613; }
.chat-go:disabled, .global-go:disabled { opacity: .45; cursor: not-allowed; }
.chat-clip { background: #242c2e; border-color: #414a47; }
.chat-empty, .global-thread .empty, .friend-note { line-height: 1.7; padding: 16px 12px; color: #a6b0ac; }
@media (hover: none) { .global-drop { opacity: .8; } }
@media (max-width: 560px) {
  .chat-thread, .global-thread { padding: 10px 8px; }
  .global-msg { padding: 10px; column-gap: 7px; }
  .global-msg time { font-size: 9px; }
  .chat-form, .global-form { padding: 9px; gap: 6px; }
  .chat-form textarea, .global-form textarea { font-size: 16px; }
}

/* Final interaction pass: clearer hierarchy and dependable touch layouts. */
#questList .list-divider { display: flex; align-items: center; gap: 10px; color: #b9b9a8; }
#questList .list-divider::after { content: ''; flex: 1; height: 1px; background: var(--edge-soft); }
#questList .quest.selected .q-select { color: #f0dfb9; }
.filters .chip { border-radius: 6px; }
.filters .chip:hover { border-color: var(--accent-dim); color: var(--text); }
.card:focus-within { border-color: var(--accent-dim); }
.card.fold > summary { cursor: pointer; }
.card.fold > summary:hover { color: #f0dfb9; }
.obj-quest .head { padding-bottom: 8px; border-bottom: 1px solid var(--edge-soft); }
.kit-item input, .obj input { margin-top: 3px; }
.kit-item, .obj { align-items: flex-start; }
.kit-item label, .obj label { min-width: 0; overflow-wrap: anywhere; }
.chat-thread, .global-thread, .chat-people, .objectives, .kit { scroll-padding-block: 12px; }
.modal-body { scroll-padding-block: 20px; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
@media (hover: hover) {
  .q-select:hover { color: var(--accent-lit); }
  .fx-option:hover { background-color: #293032; }
}
@media (max-width: 860px), (pointer: coarse) and (max-width: 1024px) {
  :root { --bar-h: 60px; }
  .panel-head { min-height: 48px; }
  .panel-head h2 { font-size: 12px; }
  .filters { gap: 9px; }
  .filters input[type="search"] { min-height: 44px; }
  .filters select { min-height: 38px; }
  .filter-row.chips { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .filters .chip { min-height: 36px; padding: 6px 9px; font-size: 11px; }
  #questList { padding: 9px; }
  #questList .quest { padding: 12px 10px; }
  .tag-btn.q-done, .tag-btn.q-copy { min-width: 36px; min-height: 36px; }
  #questList .quest { grid-template-columns: 36px minmax(0,1fr) auto; }
  .quest .q-select { font-size: 14px; }
  .mobile-bar { background: linear-gradient(180deg, rgba(199,167,107,.06), transparent), #151b1d; }
  .mobile-bar button { gap: 5px; }
  .mobile-bar button > span { font-size: 11px; font-weight: 500; }
  .mobile-bar button.on::before { left: 30%; right: 30%; }
  .map-controls.open {
    max-height: calc(var(--visible-height, 100dvh) - var(--topbar-h) - var(--bar-total) - 28px);
    border: 1px solid var(--edge); border-radius: 12px;
    padding: 10px; background: #171d1f;
    box-shadow: 0 12px 40px rgba(0,0,0,.5);
  }
  .map-controls .row { min-height: 34px; gap: 9px; }
  .map-controls .btn { min-height: 40px; }
  .map-controls .card.fold > summary { padding-block: 12px; }
  #topbar .more-menu { width: min(340px, 90vw); padding: 12px; }
  #topbar .more-menu > .btn, #topbar .more-menu > .field { min-height: 46px; }
  #topbar .more-menu .account { flex-wrap: wrap; }
  #topbar .more-menu .account .who { flex-basis: 100%; }
  #topbar .more-menu .account a { width: 40px; height: 40px; }
  .modal { top: var(--visible-top, 0px); bottom: auto; height: var(--visible-height, 100dvh); padding: 8px; }
  .modal-body { width: 100%; max-height: calc(var(--visible-height, 100dvh) - 16px); overflow-y: auto; }
  .modal-close { width: 36px; height: 36px; top: 8px; right: 8px; }
  .modal-body input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="range"]),
  .modal-body textarea, .modal-body select { font-size: 16px; }
  .modal-body .btn { min-height: 42px; }
  .profile-actions { align-items: stretch; }
  #profileSave { width: 100%; }
  .profile-msg { flex-basis: 100%; }
  /* Override persisted desktop geometry only at the mobile breakpoint. */
  .chat-dock, .chat-dock.global-dock {
    z-index: 1800;
    left: 8px !important; right: 8px !important;
    top: calc(var(--visible-top, 0px) + 8px) !important; bottom: auto !important;
    width: calc(100% - 16px) !important; min-width: 0; max-width: none;
    height: calc(var(--visible-height, 100dvh) - 16px) !important;
    max-height: calc(var(--visible-height, 100dvh) - 16px);
    border-radius: 12px;
  }
  .chat-dock.min { height: var(--dock-head, 52px) !important; }
  .chat-head { min-height: 52px; cursor: default; touch-action: auto; }
  .chat-head .chat-min, .chat-head .chat-x, .chat-head .chat-back { width: 36px; height: 36px; }
  .chat-grip { display: none; }
  .chat-form, .global-form { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .chat-go, .global-go, .chat-clip { width: 42px; height: 42px; }
  .chat-tab { min-height: 42px; }
  .chat-person { min-height: 58px; }
  .chat-bubble, .global-text { font-size: 14px; }
  .global-drop { width: 28px; height: 28px; }
}
@media (max-width: 360px) {
  .filters { padding: 9px; }
  .global-msg { grid-template-areas: 'author author' 'message message' 'time time'; }
  .global-msg time { justify-self: end; }
  .global-msg:has(.global-drop) .global-who { padding-right: 25px; }
  .global-msg:has(.global-drop) time { padding-right: 0; }
  .fx-grid { grid-template-columns: 1fr; }
}
