/* =========================================================
   Life OS — widgets.css
   Widget cards (links and embedded players) and the add box.
   ========================================================= */
.wid-section[hidden] { display: none; }
.wid-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; align-items: start; }
.wid-card {
  border: 1px solid var(--border); border-radius: 12px; background: var(--panel);
  padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 8px; min-width: 0;
}
.wid-card-embed { grid-column: span 1; }
.wid-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.wid-icon { font-size: 1.15rem; line-height: 1; flex: 0 0 auto; }
.wid-title {
  flex: 1; min-width: 0; font-weight: 600; color: var(--text); text-decoration: none;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.wid-title:hover { text-decoration: underline; }
.wid-body { display: flex; flex-direction: column; gap: 6px; }
.wid-frame { width: 100%; border: 0; border-radius: 8px; background: var(--bg-soft); display: block; }
.wid-frame-video { aspect-ratio: 16 / 9; height: auto; }
.wid-foot { font-size: 0.78rem; }
.wid-open { color: var(--accent); text-decoration: none; font-size: 0.85rem; }
.wid-open:hover { text-decoration: underline; }
.wid-foot .wid-open { font-size: inherit; }
.wid-link {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; border-radius: 8px; background: var(--hover); color: var(--text); text-decoration: none;
}
.wid-link:hover { background: var(--active); }
.wid-host { color: var(--text-muted); font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.wid-go { color: var(--accent); font-size: 0.85rem; font-weight: 600; white-space: nowrap; }

/* Add / change box */
.wid-dialog { display: flex; flex-direction: column; min-height: 0; }
.wid-dialog-title { padding: 14px 16px 6px; font-size: 1rem; color: var(--text); }
.wid-dialog-body { padding: 6px 16px 10px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }
.wid-dialog-body .pop-input { width: 100%; }
.wid-dialog-body .pop-inline .pop-field:last-child { flex: 1; }
.wid-icon-input { width: 64px !important; text-align: center; }
.wid-hint { font-size: 0.82rem; color: var(--text-muted); }
.wid-dialog-body .set-check[hidden] { display: none; }
.wid-dialog-foot { display: flex; justify-content: flex-end; align-items: center; gap: 14px; padding: 10px 16px; border-top: 1px solid var(--border); }

/* ---------- Choose a widget ---------- */
.wid-choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.wid-choice {
  display: grid; grid-template-columns: 34px 1fr; grid-template-rows: auto auto; column-gap: 8px; text-align: left;
  border: 1px solid var(--border); border-radius: 10px; background: var(--panel); padding: 10px; cursor: pointer; color: var(--text);
}
.wid-choice:hover, .wid-choice:focus-visible { background: var(--hover); border-color: var(--accent); }
.wid-choice-icon { grid-row: 1 / 3; font-size: 1.5rem; line-height: 1.2; }
.wid-choice-name { font-weight: 600; font-size: 0.92rem; }
.wid-choice-hint { font-size: 0.75rem; color: var(--text-muted); }
.wid-foot-space { flex: 1; }
.wid-dialog-foot .btn-link:first-child { margin-right: auto; }
.wid-form { display: flex; flex-direction: column; gap: 10px; }
.wid-form .pop-select { width: 100%; }
.wid-card-wide { grid-column: span 2; }
.wid-credit { font-size: 0.7rem; color: var(--text-faint); margin-top: 6px; }
.wid-error { font-size: 0.82rem; color: var(--fin-bad-text, var(--danger)); margin-top: 6px; }
.wid-live { min-height: 60px; }
.rt-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.rt-actions .btn-small { margin: 0; text-decoration: none; color: var(--text); }

/* Place box with suggestions */
.geo-place { position: relative; }
.geo-suggest {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 5; margin-top: 2px; max-height: 220px; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow);
}
.geo-suggest[hidden] { display: none; }
.geo-option { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 8px 10px; cursor: pointer; color: var(--text); font-size: 0.88rem; }
.geo-option:hover, .geo-option:focus { background: var(--hover); }
.geo-status { font-size: 0.78rem; min-height: 1em; margin-top: 2px; }

/* Small map */
.geo-map { position: relative; overflow: hidden; border-radius: 10px; background: #e8e6e1; }
:root[data-theme="dark"] .geo-map { background: #2a2a2a; }
.geo-tiles { position: absolute; inset: 0; }
.geo-tile { position: absolute; width: 256px; height: 256px; max-width: none; user-select: none; }
:root[data-theme="dark"] .geo-tile { filter: brightness(0.82) contrast(1.05); }
.geo-overlay { position: absolute; inset: 0; pointer-events: none; }
.geo-line-casing { fill: none; stroke: #fff; stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; opacity: 0.9; }
.geo-line { fill: none; stroke: #2a78d6; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.geo-pin { stroke: #fff; stroke-width: 3; }
.geo-credit { position: absolute; right: 4px; bottom: 3px; font-size: 0.62rem; color: #444; background: rgba(255, 255, 255, 0.8); padding: 0 4px; border-radius: 3px; }
.wid-map-label { font-size: 0.85rem; color: var(--text-muted); margin-top: 6px; }

/* Weather */
.wx-now { display: grid; grid-template-columns: auto auto 1fr; align-items: center; gap: 10px; }
.wx-emoji { font-size: 2.2rem; line-height: 1; }
.wx-temp { font-size: 2.2rem; font-weight: 700; line-height: 1; }
.wx-desc { font-size: 0.9rem; min-width: 0; }
.wx-days { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-top: 10px; }
.wx-day { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; border-radius: 8px; background: var(--hover); font-size: 0.78rem; }
.wx-day-name { color: var(--text-muted); }
.wx-day-emoji { font-size: 1.2rem; }
.wx-day-temp { font-weight: 600; white-space: nowrap; }
.wx-day-rain { color: var(--text-muted); font-size: 0.7rem; }

/* Route maker */
.rt-ends { display: grid; grid-template-columns: 12px 1fr; gap: 4px 8px; align-items: center; font-size: 0.85rem; margin-bottom: 8px; }
.rt-dot { width: 10px; height: 10px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--border); }
.rt-start { background: #0ca30c; }
.rt-end { background: #e5484d; }
.rt-place { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rt-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 10px; min-height: 40px; }
.rt-stat { display: flex; flex-direction: column; background: var(--hover); border-radius: 8px; padding: 6px 10px; }
.rt-stat b { font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.rt-stat span { font-size: 0.72rem; color: var(--text-muted); }
.rt-wx { font-size: 0.82rem; margin-top: 8px; }

/* Exchange rates */
.fx-top { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.fx-amount { width: 90px !important; font-size: 1rem; font-weight: 600; }
.fx-base { color: var(--text-muted); font-weight: 600; }
.fx-rows { display: flex; flex-direction: column; }
.fx-row { display: flex; justify-content: space-between; padding: 6px 2px; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.fx-row:last-child { border-bottom: 0; }
.fx-code { color: var(--text-muted); }
.fx-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 4px; max-height: 160px; overflow-y: auto; }
.fx-pick-item { display: flex; align-items: center; gap: 4px; font-size: 0.82rem; cursor: pointer; }

/* Countdown */
.cd { text-align: center; padding: 6px 0; }
.cd-num { font-size: 3rem; font-weight: 700; line-height: 1.1; }
.cd-label { font-weight: 600; margin-bottom: 4px; }
.cd.past .cd-num { color: var(--text-faint); }

/* Color palette */
.pal-row { display: flex; height: 92px; border-radius: 10px; overflow: hidden; }
.pal-swatch { flex: 1; border: 0; cursor: pointer; display: flex; align-items: flex-end; justify-content: center; padding: 6px 2px; min-width: 0; }
.pal-swatch:hover { flex: 1.3; }
.pal-hex { font-size: 0.68rem; font-family: ui-monospace, Consolas, monospace; letter-spacing: -0.02em; }
.pal-mini { height: 26px; margin-top: 4px; }
.pal-mini .pal-swatch { cursor: default; }

/* Creative prompt */
.pr-topic { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 4px; }
.pr-text { font-size: 1.05rem; line-height: 1.45; font-weight: 500; }

/* Sticky note */
.sticky { position: relative; border-radius: 8px; padding: 2px; }
.sticky-text {
  width: 100%; border: 0; outline: none; resize: none; background: transparent; color: #3a3320; font: inherit; font-size: 0.95rem;
  line-height: 1.5; padding: 8px 10px 18px; min-height: 110px;
}
.sticky-status { position: absolute; right: 8px; bottom: 4px; font-size: 0.68rem; color: rgba(0, 0, 0, 0.45); }
.sticky-yellow { background: #fff4b8; }
.sticky-pink { background: #ffd9e4; }
.sticky-blue { background: #d6e9ff; }
.sticky-green { background: #d8f3d8; }
:root[data-theme="dark"] .sticky-yellow { background: #5a5226; }
:root[data-theme="dark"] .sticky-pink { background: #5b3442; }
:root[data-theme="dark"] .sticky-blue { background: #2b4060; }
:root[data-theme="dark"] .sticky-green { background: #2e4d33; }
:root[data-theme="dark"] .sticky-text { color: #f2eedf; }
:root[data-theme="dark"] .sticky-status { color: rgba(255, 255, 255, 0.5); }

/* To-do list and Note widgets */
.wid-todos .task-add { margin-top: 0; }
.wid-note .wn-title { font-weight: 700; font-size: 1.02rem; margin-bottom: 4px; }
.wid-note-body { font-size: 0.92rem; line-height: 1.5; }
.wn-h { font-weight: 600; margin-top: 8px; }
.wn-p { margin: 4px 0; }
.wn-li { margin: 2px 0; }
.wn-check { display: flex; align-items: flex-start; gap: 8px; margin: 3px 0; cursor: pointer; }
.wn-check input { margin-top: 4px; accent-color: var(--accent); }
.wn-check.done span { color: var(--text-faint); text-decoration: line-through; }

/* Board inside a custom tab */
.wid-bare { margin-top: 0; }
.wid-bare .lg-wrap { margin-top: 4px; }

@media (max-width: 700px) {
  .wid-card-wide { grid-column: auto; }
}
@media (max-width: 420px) {
  .wid-grid { grid-template-columns: 1fr; }
  .wx-days { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
