.hb-screen { display:grid; gap:20px; min-width:0; }
.hb-intro { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:16px; }
.hb-intro h3 { margin:0 0 8px; }.hb-intro p { margin:0; color:var(--muted); }
.hb-metrics { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:16px; }
.hb-metrics .card { display:grid; gap:12px; padding:20px; }.hb-metrics strong { font-size:30px; color:var(--brand-strong); }.hb-metrics small { color:var(--muted); }
.hb-screen table { width:100%; min-width:750px; }.hb-screen th:first-child { min-width:220px; }.hb-screen td,.hb-screen th { text-align:center; }.hb-screen th:first-child { text-align:left; }
.hb-screen table small { display:block; margin-top:6px; color:var(--muted); font-size:11px; }
.hb-check { display:inline-grid; place-items:center; width:30px; height:30px; border-radius:50%; font-weight:700; font-size:18px; }
.hb-check.yes { color:var(--brand-strong); background:var(--brand-soft); }.hb-check.no { color:#b44949; background:#fff0ef; }.hb-check.pending { color:var(--muted); background:var(--surface-soft); }
.hb-money-mask { display:inline-block; color:var(--muted); text-decoration:line-through; letter-spacing:3px; }.hb-money-mask.blurred { text-decoration:none; filter:blur(3px); }
.hb-legend { color:var(--muted); font-size:12px; }.hb-screen #habitWeekNotes { display:grid; gap:16px; }.hb-screen #habitWeekNotes label { display:grid; gap:8px; }.hb-screen textarea { width:100%; min-height:90px; }
.hb-screen .toolbar input[type="week"] { max-width:210px; }.hb-screen .card { min-width:0; }
.trade-week-field small { display:block; line-height:1.6; color:var(--muted); }.trade-week-field [data-week-auto] { margin-top:6px; text-align:left; }
@media(max-width:760px) { .hb-metrics { grid-template-columns:1fr; }.hb-screen .toolbar { gap:16px; }.hb-screen .toolbar-left { width:100%; }.hb-screen .toolbar > label { width:100%; display:grid; gap:8px; } }

/* Keep the image and editor together, with sharing actions outside the scrolling area. */
:root #modalRoot .modal.hb-preview {
  width: min(1480px, calc(100vw - 24px));
  height: calc(100dvh - 24px);
  max-height: calc(100dvh - 24px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
:root #modalRoot .hb-preview .modal-header { flex: 0 0 auto; padding: 16px 22px; }
:root #modalRoot .hb-preview .modal-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 16px 22px;
  overflow: auto;
  overscroll-behavior: contain;
  background: var(--surface-soft);
}
.hb-share-content { display: grid; gap: 14px; max-width: 1260px; margin-inline: auto; }
.hb-share-stage {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 80px;
  margin: 0;
  padding: clamp(8px, 1.6vw, 16px);
  border: 1px solid var(--line);
  border-radius: 16px;
  background: color-mix(in srgb, var(--brand-soft) 55%, var(--surface));
}
.hb-share-stage img {
  display: block;
  width: min(100%, calc(max(220px, 100dvh - 220px) * 2400 / 1900));
  height: auto;
  max-width: 100%;
  border-radius: 10px;
  box-shadow: 0 6px 20px color-mix(in srgb, var(--brand) 14%, transparent);
}
.hb-share-stage img:not([src]) { visibility: hidden; }
.hb-share-panel {
  min-width: 0;
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}
.hb-share-panel label { display: grid; gap: 6px; min-width: 0; }
.hb-share-label { color: var(--text); font-weight: 650; }
.hb-share-hint, #habitProfileStatus, .hb-share-translations p { color: var(--muted); font-size: .8125rem; }
:root #modalRoot .hb-preview .hb-share-panel textarea {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 9rem;
  max-height: 32rem;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
  line-height: 1.55;
  field-sizing: content;
  resize: vertical;
}
:root #modalRoot .hb-preview .hb-share-panel textarea:focus {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
.hb-share-save { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
.hb-share-translations summary { color: var(--text); font-weight: 600; cursor: pointer; }
.hb-share-translations form { display: grid; gap: 10px; margin-top: 10px; }
.hb-share-translations form p { margin: 0; }
.hb-share-translations form .button { justify-self: start; }
:root #modalRoot .hb-preview .hb-share-actions {
  flex: 0 0 auto;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 12px 22px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}
#modalRoot .hb-share-actions .button { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }
.hb-share-actions svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.hb-share-actions [aria-disabled=true] { pointer-events: none; opacity: .5; }
@media (max-width: 700px) {
  :root #modalRoot .modal.hb-preview { width: calc(100vw - 12px); height: calc(100dvh - 12px); max-height: calc(100dvh - 12px); }
  :root #modalRoot .hb-preview :is(.modal-header, .modal-body, .hb-share-actions) { padding: 10px 12px; }
  :root #modalRoot .hb-preview .modal-header h2 { font-size: 18px; }
  .hb-share-content { gap: 10px; }
  .hb-share-panel { padding: 12px; }
  .hb-share-save .button { width: 100%; }
  :root #modalRoot .hb-preview .hb-share-actions { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 6px; }
  :root #modalRoot .hb-preview .hb-share-actions .button { min-width: 0; padding: 8px 4px; font-size: .75rem; justify-content: center; gap: 5px; }
  .hb-share-actions svg { width: 15px; height: 15px; }
}
/* Daily habit editor: compact fields and persistent save actions. */
:root #modalRoot .modal.hb-editor { width:min(1120px,calc(100vw - 40px)); max-height:calc(100dvh - 40px); overflow:hidden; display:flex; flex-direction:column; }
:root #modalRoot .hb-editor .modal-header { flex:0 0 auto; padding:14px 22px; }
:root #modalRoot .hb-editor #habitEntryForm { min-height:0; display:flex; flex-direction:column; }
:root #modalRoot .hb-editor .modal-body { min-height:0; display:flex; flex-direction:column; padding:0; overflow:hidden; }
:root #modalRoot .hb-editor .form-grid { overflow:auto; min-height:0; padding:14px 22px; gap:12px 18px; grid-template-columns:repeat(3,minmax(0,1fr)); }
:root #modalRoot .hb-editor .field { min-width:0; gap:5px; }
:root #modalRoot .hb-editor .field.full { grid-column:1 / -1; }
:root #modalRoot .hb-editor .field :is(input:not([type=checkbox]),select) { min-height:38px; padding:8px 10px; }
:root #modalRoot .hb-editor textarea { min-height:60px; height:65px; resize:vertical; }
:root #modalRoot .hb-editor .modal-footer { flex:0 0 auto; padding:12px 22px; border-top:1px solid var(--line); background:var(--surface); }
@media(max-width:760px) {
  :root #modalRoot .modal.hb-editor { width:calc(100vw - 20px); max-height:calc(100dvh - 24px); }
  :root #modalRoot .hb-editor .form-grid { grid-template-columns:repeat(2,minmax(0,1fr)); padding:10px 14px; gap:10px; }
  :root #modalRoot .hb-editor .modal-header { padding:10px 14px; }
  :root #modalRoot .hb-editor .modal-footer { padding:10px 14px; }
}
@media(max-width:420px) { :root #modalRoot .hb-editor .form-grid { grid-template-columns:minmax(0,1fr); } }
/* Show the whole weekly habits table, including the daily edit buttons. */
:root .finance-screen .hb-screen .table-wrap,
:root .discipline-screen .hb-screen .table-wrap,
:root .hb-screen .table-wrap {
  height:auto;
  max-height:none;
  overflow-x:auto;
  overflow-y:auto;
}
:root .hb-screen .table-wrap :is(th,td) { padding:8px 12px; }
:root .hb-screen .table-wrap td small { line-height:1.25; }
