/* Management surfaces share the table's controls, with quieter secondary actions. */
:root {
  --cream: #f4ead8;
  --blue: #2598ee;
  --red: #f35c60;
  --gold: #f6c566;
  --dark: #263b3c;
  --panel: #34484b;
  --muted: #a9bcbc;
  --font: 'Chakra Petch', 'Courier New', 'Microsoft YaHei', monospace;
  --ease-out: cubic-bezier(0.18, 0.78, 0.2, 1);
  --control-radius: 7px;
  --control-edge: #b9d2c12e;
  --control-face: #254e43;
  --control-text: #e2eadb;
  --control-shadow: 0 3px 0 #092f29b3, inset 0 1px 0 #ffffff16;
  --ui-surface: #203b34;
  --ui-surface-raised: #2d4840;
  --ui-text: #f2efdf;
  --ui-muted: #baccc1;
  --ui-border: #829e91;
  --ui-focus: #f3d18a;
  --ui-blue: #256d9c;
  --ui-red: #9c494c;
  --ui-green: #35684f;
  --ui-gold: #dfb669;
  --panel-bg: #203b34;
  --panel-edge: #7c9f8c66;
  --panel-soft: #b6cec1;
  --panel-gap: 16px;
}
.home-resume {
  border: 1px solid #71978a;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  text-align: left;
  padding: 22px;
  border-color: #87ae96;
  background: #173e32;
  box-shadow: 0 8px 28px #072c2333;
}
#home-progress {
  order: -1;
  line-height: 1.6;
  color: var(--panel-soft);
  font-size: 14px;
  overflow-wrap: anywhere;
}
#home-progress > strong {
  display: block;
  color: var(--ui-text);
  font-size: 20px;
  margin-bottom: 10px;
}
.progress-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.progress-tags > span {
  padding: 3px 8px;
  background: #092c2666;
  border: 1px solid #94b3a333;
  border-radius: 5px;
  font-size: 13px;
  white-space: nowrap;
}
.home-links {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.home-links button {
  padding: 12px;
  background: #274c42;
  border: 1px solid #648377;
  border-radius: 8px;
  min-height: 46px;
  color: var(--ui-text);
}
.home-view #home-status {
  font-size: 13px;
  line-height: 1.6;
  overflow-wrap: anywhere;
  margin: 0;
  padding: 12px 0;
  border-top: 1px solid #9abb9e33;
}
.at-home footer #save-status {
  display: none;
}
#modal:not(.shop-dialog) {
  width: min(780px, calc(100vw - 32px));
  max-height: 90dvh;
  background: var(--panel-bg);
  padding: 0;
}
#modal:not(.shop-dialog) .modal-inner {
  padding: 0 24px 24px;
}
#modal:not(.shop-dialog) .modal-header {
  position: sticky;
  top: 0;
  z-index: 4;
  isolation: isolate;
  display: flex;
  gap: 12px;
  align-items: center;
  margin: 0 -24px 20px;
  padding: 18px 24px;
  background: var(--panel-bg);
  border-bottom: 1px solid var(--panel-edge);
}
.modal-header h2 {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 24px;
  line-height: 1.3;
}
body #dialog-home {
  font-size: 14px;
  padding: 8px 10px;
  min-height: 40px;
  white-space: nowrap;
  color: var(--ui-text);
  background: var(--control-face);
}
#modal p {
  line-height: 1.65;
  font-size: 16px;
}
#modal p.muted {
  font-size: 14px;
  color: var(--panel-soft);
}
#modal .modal-actions {
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
  margin-bottom: 18px;
}
body #modal .save-row {
  background: #172f29;
  border: 1px solid var(--panel-edge);
  border-radius: 10px;
  padding: 16px;
  gap: 9px;
  min-width: 0;
  box-shadow: none;
  margin: 0;
}
.save-row > strong {
  font-size: 17px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.save-row > small {
  line-height: 1.65;
  overflow-wrap: anywhere;
  color: var(--panel-soft);
}
.save-row > span {
  line-height: 1.6;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}
.save-row > div:not(.device-heading) {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
body #modal .save-row button {
  margin: 0;
  min-height: 40px;
  padding: 9px 13px;
  font-size: 14px;
}
body #modal .primary-control {
  background: var(--ui-blue);
  color: var(--ui-text);
  border-color: #9fcee866;
}
body
  #modal
  :is(
    .danger-control,
    [data-save-action='delete'],
    [data-cloud-delete],
    [data-session-revoke],
    #revoke-others
  ) {
  background: transparent;
  color: #ffc0b7;
  border-color: #ba847566;
  box-shadow: none;
}
body #modal [data-save-action='delete'] {
  margin-left: auto;
}
.account-identity {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: center;
  margin: 16px 0;
}
.account-identity strong {
  font-size: 20px;
  overflow-wrap: anywhere;
}
.account-identity span {
  font-size: 14px;
  color: var(--panel-soft);
}
#sync-live {
  padding: 14px 16px;
  border: 1px solid var(--panel-edge);
  border-left: 4px solid #a3c6b0;
  border-radius: 7px;
  background: #102c25;
  font-size: 14px !important;
  line-height: 1.6;
  margin: 0 0 16px;
  overflow-wrap: anywhere;
}
#sync-live:empty {
  display: none;
}
#sync-live[data-state='conflict'],
#sync-live[data-state='pending'],
#sync-live[data-state='remote'] {
  border-left-color: #ebc16e;
}
#sync-live[data-state='error'] {
  border-left-color: #f08c85;
}
#sync-live[data-state='syncing'] {
  border-left-color: #78bfe9;
}
#modal details > summary {
  font-size: 14px;
  line-height: 1.5;
  cursor: pointer;
  min-height: 44px;
  padding: 12px 0;
  color: #dfd9bd;
}
#modal details > summary:focus-visible {
  outline: 2px solid var(--ui-focus);
  outline-offset: 3px;
  border-radius: 4px;
}
body #modal .sync-result {
  background: #1b382d;
  border-color: var(--panel-edge);
  padding: 16px;
  margin: 16px 0 24px;
}
#modal .sync-result h3 {
  font-size: 17px;
}
#modal .sync-result p {
  font-size: 14px;
}
#modal .sync-result .save-row {
  margin-block: 8px;
}
#modal .section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  border-top: 1px solid var(--panel-edge);
  padding-top: 22px;
  margin: 24px 0 14px;
  font-size: 19px;
}
.section-title small {
  font-size: 13px;
  color: var(--panel-soft);
  font-weight: 400;
}
#modal .quiet-status {
  font-size: 14px;
  color: var(--panel-soft);
  padding: 12px 0;
  margin: 12px 0;
}
#modal .empty-state {
  font-size: 15px;
  text-align: center;
  padding: 24px 16px;
  color: var(--panel-soft);
  border: 1px dashed var(--panel-edge);
  border-radius: 10px;
}
#modal .pending-list {
  gap: 12px;
}
.record-id {
  font-size: 12px;
  overflow-wrap: anywhere;
}
.device-heading {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}
.device-heading strong {
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.device-heading button {
  flex: none;
}
.device-list details .save-row {
  margin-top: 8px !important;
}
@media (max-width: 700px) {
  body #modal .modal-actions .action {
    min-width: 0;
    width: 100%;
    min-height: 44px;
    padding: 10px;
    font-size: 14px;
  }
  body #modal .save-row button {
    min-height: 44px;
    flex-grow: 1;
  }
}
/* Primary actions stay visible; metadata and maintenance live behind disclosure. */
#modal .secondary-menu {
  min-width: 0;
  margin: 12px 0;
  border: 0;
  background: transparent;
}
#modal .secondary-menu > summary {
  color: var(--panel-soft);
  font-size: 14px;
}
#modal .secondary-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 14px;
}
body #modal .secondary-actions button {
  min-height: 40px;
  padding: 9px 12px;
  background: var(--control-face);
  color: var(--ui-text);
  font-size: 14px;
}
#modal .record-actions {
  display: grid !important;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 12px !important;
}
#modal .record-menu {
  margin: 0;
  min-width: 0;
}
#modal .record-menu > summary {
  min-height: 40px;
  padding: 9px 8px;
  text-align: right;
}
#modal .record-menu[open] {
  grid-column: 1/-1;
}
#modal .record-menu[open] > summary {
  text-align: left;
  padding-inline: 0;
}
#modal .record-menu p {
  font-size: 14px;
  color: var(--panel-soft);
}
#modal .account-primary {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 14px 0;
}
#modal .account-primary .action {
  min-height: 44px;
  padding: 12px 16px;
}
#modal .sync-result {
  padding: 0 14px !important;
  background: transparent !important;
  border-color: var(--panel-edge) !important;
  margin: 16px 0 !important;
}
#modal .sync-result > summary {
  color: var(--ui-text);
  font-size: 14px;
  line-height: 1.7;
  padding: 12px 0;
  overflow-wrap: anywhere;
}
.home-view {
  width: min(520px, calc(100% - 32px));
  text-align: center;
  display: grid;
  gap: 20px;
  margin-top: clamp(32px, 8vh, 90px);
}
.home-view h1 {
  margin: 0;
  letter-spacing: 0.14em;
  font-size: clamp(30px, 5vw, 42px);
  margin-bottom: 8px;
}
@media (max-width: 700px) {
  .home-resume {
    padding: 18px;
  }
  .home-links {
    gap: 10px;
  }
  #modal:not(.shop-dialog) {
    width: calc(100vw - 16px);
    max-height: 94dvh;
  }
  #modal:not(.shop-dialog) .modal-inner {
    padding: 0 16px 20px;
  }
  #modal:not(.shop-dialog) .modal-header {
    margin: 0 -16px 16px;
    padding: 12px 16px;
    gap: 8px;
  }
  .modal-header h2 {
    font-size: 20px;
  }
  body #dialog-home {
    padding: 8px;
    font-size: 13px;
    min-height: 44px;
  }
  #modal .modal-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  /* An odd last button (usually the primary action) takes the full row instead of half of it. */
  #modal .modal-actions > :last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }
  body #modal .save-row {
    padding: 14px;
  }
  body #modal .device-heading button {
    flex-grow: 0;
  }
  #modal > .toast {
    right: 12px;
    max-width: calc(100% - 24px);
  }
  body #modal .secondary-actions button {
    min-height: 44px;
  }
  #modal .record-menu > summary {
    min-height: 44px;
  }
  .home-view {
    gap: 14px;
    margin-top: 32px;
  }
}
