:root {
  color-scheme: dark;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bg: #0e1116;
  --surface: #161a21;
  --surface-2: #1d222b;
  --field: #11151b;
  --border: #262b35;
  --border-strong: #353c49;
  --text: #e7eaf0;
  --text-muted: #98a1b2;
  --accent: #3b6fe0;
  --accent-hover: #2f5cc4;
  --accent-text: #82a6ff;
  --accent-soft: rgba(59, 111, 224, 0.16);
  --danger: #f2696e;
  --danger-hover: #d1454b;
  --danger-surface: rgba(242, 105, 110, 0.12);
  --danger-border: rgba(242, 105, 110, 0.38);
  --success: #4cd98b;
  --success-surface: rgba(76, 217, 139, 0.12);
  --success-border: rgba(76, 217, 139, 0.38);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

/* Components below set an explicit display, which would otherwise win over
   the browser default for [hidden]. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ---- Navigation ------------------------------------------------------- */

.nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0 1.5rem;
  height: 3.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.nav-brand {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.nav-links {
  display: flex;
  gap: 0.25rem;
}

.nav-links a {
  padding: 0.45rem 0.75rem;
  border-radius: 6px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.95rem;
}

.nav-links a:hover {
  color: var(--text);
  background: var(--surface-2);
}

.nav-links a[aria-current="page"] {
  color: var(--accent-text);
  background: var(--accent-soft);
  font-weight: 600;
}

.nav-links a[aria-current="page"]:hover {
  color: var(--accent-text);
  background: var(--accent-soft);
}

.nav-user {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-muted);
  font-size: 0.875rem;
  white-space: nowrap;
}

/* ---- Layout ----------------------------------------------------------- */

.content {
  max-width: 72rem;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.content-wide {
  max-width: 92rem;
}

.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

/* ---- Cards ------------------------------------------------------------ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-head {
  padding: 1.5rem 1.5rem 0;
}

.card-body {
  padding: 1.5rem;
}

.card-head + .card-body {
  padding-top: 1rem;
}

.auth .card {
  width: 100%;
  max-width: 22rem;
  padding: 2rem;
}

.auth h1 {
  margin: 0 0 0.25rem;
  font-size: 1.5rem;
}

h1 {
  margin: 0 0 0.25rem;
  font-size: 1.5rem;
}

.subtitle {
  margin: 0 0 1.5rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.page-title {
  margin-bottom: 0.25rem;
}

.page-subtitle {
  margin: 0 0 1.5rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ---- Forms ------------------------------------------------------------ */

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  font-weight: 500;
}

input,
select {
  padding: 0.6rem 0.75rem;
  font-size: 1rem;
  color: var(--text);
  background: var(--field);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
}

input::placeholder {
  color: var(--text-muted);
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

textarea {
  padding: 0.6rem 0.75rem;
  font: inherit;
  font-size: 1rem;
  color: var(--text);
  background: var(--field);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  resize: vertical;
}

textarea::placeholder {
  color: var(--text-muted);
}

.form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
}

.form-row label {
  flex: 1 1 9rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 0.75rem;
}

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.form-grid .btn {
  align-self: end;
}

.inline-form {
  display: inline;
  margin: 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---- Drive file browser ------------------------------------------------ */

.drive-page {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.drive-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.9rem 1.25rem;
}

.drive-crumbs {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
  font-size: 1.05rem;
  font-weight: 600;
  min-width: 0;
  flex-wrap: wrap;
}

.drive-crumb {
  color: var(--text);
  text-decoration: none;
}

.drive-crumb:hover {
  text-decoration: underline;
}

.drive-crumb-sep {
  color: var(--text-muted);
}

.drive-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.drive-mkdir {
  display: inline-flex;
  gap: 0.4rem;
}

.drive-mkdir input[type="text"] {
  width: 9rem;
}

.drive-error {
  margin: 0;
}

.drive-list {
  padding: 0.4rem 0;
}

.drive-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 7rem 11rem 6rem;
  gap: 0.75rem;
  align-items: center;
  padding: 0.55rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.drive-row:last-child {
  border-bottom: none;
}

.drive-row-head {
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.drive-cell-name {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drive-cell-name a {
  color: var(--text);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
}

.drive-cell-name a:hover {
  text-decoration: underline;
}

.drive-cell-size,
.drive-cell-date {
  color: var(--text-muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

.drive-cell-ops {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.15rem;
}

.drive-op {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  border-radius: 6px;
  text-decoration: none;
  line-height: 1;
}

.drive-op:hover {
  color: var(--text);
  background: var(--surface-hover, rgba(255, 255, 255, 0.06));
}

@media (max-width: 640px) {
  .drive-row {
    grid-template-columns: minmax(0, 1fr) 4.5rem;
  }
  .drive-cell-date,
  .drive-row-head .drive-cell-date,
  .drive-row-head .drive-cell-ops {
    display: none;
  }
}

/* ---- Photo gallery ------------------------------------------------------- */

.gallery-page {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.gallery-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1rem 1.25rem;
}

/* Photo detail: large stage plus a narrow side column. */
.photo-page {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.photo-back {
  text-decoration: none;
}

.photo-stage {
  display: flex;
  justify-content: center;
  padding: 1rem;
  background: #111;
}

.photo-large {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
}

.photo-side {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
}

.photo-meta dl {
  display: grid;
  gap: 0.35rem;
  margin: 0.75rem 0;
}

.photo-name {
  font-size: 1.1rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
  margin: 0;
}

.photo-meta dl > div {
  display: flex;
  gap: 0.5rem;
}

.photo-meta dt {
  font-weight: 600;
  min-width: 5.5rem;
  flex-shrink: 0;
}

.photo-meta dd {
  margin: 0;
  overflow-wrap: anywhere;
}

/* Reusable photo tags. */
.tag-chip {  display: inline-block;
  background: rgba(127, 127, 127, 0.2);
  border-radius: 999px;
  padding: 0.1rem 0.6rem;
  margin: 0.1rem;
  font-size: 0.85rem;
  white-space: nowrap;
}

.tag-chip-removable button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0 0 0 0.25rem;
}

.tag-chips {
  margin-bottom: 0.75rem;
}

.gallery-caption .tag-chip {
  font-size: 0.75rem;
}

.tag-form {
  position: relative;
}

.tag-suggest[hidden] {
  display: none;
}

.tag-suggest {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  z-index: 5;
  display: flex;
  flex-direction: column;
  background: var(--card-bg, #1c1c1e);
  border: 1px solid rgba(127, 127, 127, 0.4);
  border-radius: 0.5rem;
  overflow: hidden;
}

.tag-suggest-item {
  background: none;
  border: none;
  text-align: left;
  padding: 0.6rem 0.8rem;
  font-size: 1rem;
  cursor: pointer;
}

.tag-suggest-item + .tag-suggest-item {
  border-top: 1px solid rgba(127, 127, 127, 0.25);
}

/* Gallery layout with filter sidebar. */
.gallery-layout {
  display: grid;
  grid-template-columns: 13rem 1fr;
  gap: 1rem;
  align-items: start;
}

.gallery-nav {
  position: sticky;
  top: 1rem;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.gallery-nav h3 {
  margin: 0.75rem 0 0.25rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.gallery-nav-link {
  text-decoration: none;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.3rem 0.5rem;
  border-radius: 0.4rem;
  overflow-wrap: anywhere;
}

.gallery-nav-link.active,
.gallery-nav-row.active .gallery-nav-link {
  font-weight: 700;
}

.gallery-nav-count {
  opacity: 0.6;
  font-size: 0.85rem;
}

.gallery-nav-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem;
}

.gallery-nav-row .gallery-nav-link {
  flex: 1;
  min-width: 0;
}

.gallery-nav-row.drop-hint .gallery-nav-link {
  background: rgba(10, 132, 255, 0.25);
  outline: 2px dashed rgba(10, 132, 255, 0.8);
}

.gallery-open[draggable="true"] {
  cursor: grab;
}

.gallery-open[draggable="true"]:active {
  cursor: grabbing;
}

.gallery-nav-new {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.gallery-nav-new input {
  flex: 1;
  min-width: 0;
}

.gallery-filter {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
}

.upload-progress {
  width: 100%;
}

.gallery-main {
  min-width: 0;
}

.album-checks {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}

.album-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

@media (max-width: 46rem) {
  .gallery-layout {
    grid-template-columns: 1fr;
  }
  .gallery-nav {
    position: static;
  }
}

/* Gallery lightbox modal. */
.gallery-open {
  background: none;
  border: none;
  padding: 0;
  cursor: zoom-in;
  width: 100%;
  position: relative;
}

.gallery-open img {
  width: 100%;
  display: block;
}

/* Multi-select: checkable thumbnails plus the bulk action bar. */
body.select-mode .gallery-open {
  cursor: pointer;
}

.gallery-open.selected {
  outline: 3px solid var(--accent, #0a84ff);
  outline-offset: -3px;
  border-radius: 4px;
}

.gallery-open.selected img {
  filter: brightness(0.82);
}

/* Checkmark badge, drawn only while selecting so it never covers art. */
body.select-mode .gallery-open {
  position: relative;
}

body.select-mode .gallery-open::after {
  content: "";
  position: absolute;
  top: 8px;
  left: 8px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.9);
  background: rgba(0, 0, 0, 0.35);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

body.select-mode .gallery-open.selected::after {
  content: "\2713";
  color: #fff;
  font-size: 13px;
  line-height: 20px;
  text-align: center;
  background: var(--accent, #0a84ff);
  border-color: var(--accent, #0a84ff);
}

.select-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  padding: 0.6rem 0.9rem;
  position: sticky;
  top: 0.5rem;
  z-index: 5;
}

.select-bar[hidden] {
  display: none;
}

.select-bar [data-bulk-tag] {
  max-width: 12rem;
}

.select-bar [data-bulk-delete] {
  color: var(--danger, #d7263d);
}

.photo-modal[hidden] {
  display: none;
}

.photo-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.photo-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
}

.photo-modal-box {
  position: relative;
  max-width: 56rem;
  width: 100%;
  max-height: 90vh;
  overflow: auto;
  display: grid;
  gap: 1rem;
  grid-template-columns: 2fr 1fr;
}

.photo-modal-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #111;
  border-radius: 0.5rem;
  min-height: 12rem;
}

.photo-modal-side {
  min-width: 0;
}

.photo-modal-x {
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
  background: none;
  border: none;
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
}

.photo-modal-nav {
  position: absolute;
  top: 40%;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 2.25rem;
  height: 2.25rem;
  font-size: 1.25rem;
  cursor: pointer;
}

.photo-modal-prev {
  left: 0.5rem;
}

.photo-modal-next {
  right: 0.5rem;
}

.photo-modal-meta {
  display: grid;
  gap: 0.35rem;
  margin: 0.75rem 0;
}

.photo-modal-meta > div {
  display: flex;
  gap: 0.5rem;
}

.photo-modal-meta dt {
  font-weight: 600;
  min-width: 3.5rem;
  flex-shrink: 0;
}

.photo-modal-meta dd {
  margin: 0;
  overflow-wrap: anywhere;
}

@media (max-width: 40rem) {
  .photo-modal-box {
    grid-template-columns: 1fr;
  }
}

.gallery-title {
  margin: 0;
  font-size: 1.4rem;
}

.gallery-month-title {
  font-size: 1.05rem;
  color: var(--text-muted);
  margin: 0.5rem 0 0.75rem;
  font-weight: 600;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.75rem;
}

.gallery-item {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface);
  min-height: 120px;
  display: flex;
  flex-direction: column;
}

.gallery-item img,
.gallery-item video {
  width: 100%;
  height: 150px;
  object-fit: cover;
  display: block;
  background: #000;
}

.gallery-caption {
  padding: 0.4rem 0.6rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-file-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  height: 150px;
  color: var(--text);
  text-decoration: none;
  padding: 0.5rem;
  text-align: center;
  overflow: hidden;
}

.gallery-file-icon {
  font-size: 2rem;
}

/* Play badge over a video poster thumbnail. pointer-events keep it a
   decoration: the click still opens the lightbox on the button. */
.gallery-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 1.05rem;
  line-height: 44px;
  text-align: center;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}

/* ---- Buttons ---------------------------------------------------------- */

button {
  font: inherit;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.7rem 1rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
}

.btn:hover {
  background: var(--accent-hover);
}

.btn:disabled {
  opacity: 0.6;
  cursor: progress;
}

.btn-ghost {
  color: var(--text-muted);
  background: transparent;
}

.btn-ghost:hover {
  color: var(--text);
  background: var(--surface-2);
}

.btn-danger {
  color: var(--danger);
  background: transparent;
}

.btn-danger:hover {
  color: #fff;
  background: var(--danger-hover);
}

.btn-sm {
  padding: 0.4rem 0.6rem;
  font-size: 0.85rem;
}

/* ---- Contacts -------------------------------------------------------- */

.contacts-page {
  display: grid;
  grid-template-columns: minmax(17rem, 21rem) minmax(0, 1fr);
  min-height: min(43rem, calc(100vh - 7.5rem));
}

.contacts-sidebar {
  display: flex;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--radius) 0 0 var(--radius);
  box-shadow: none;
}

.contacts-sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.contacts-sidebar-head .page-title {
  font-size: 1.25rem;
}

.contacts-count {
  margin: 0.2rem 0 0;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.btn-square {
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  font-size: 1.35rem;
}

.contacts-error {
  margin: 0.75rem;
}

.contact-list {
  min-height: 12rem;
  flex: 1;
  overflow-y: auto;
}

.contact-list-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  transition: background-color 120ms ease;
}

.contact-list-item:hover {
  background: var(--surface-2);
}

.contact-list-item.is-active {
  background: var(--accent-soft);
  box-shadow: inset 3px 0 var(--accent);
}

.contact-list-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.contact-list-copy strong,
.contact-list-copy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.contact-list-copy strong {
  font-size: 0.925rem;
}

.contact-list-copy span {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.contact-avatar {
  display: inline-grid;
  width: 5rem;
  height: 5rem;
  flex: 0 0 auto;
  place-items: center;
  color: var(--accent-text);
  background: var(--accent-soft);
  border: 1px solid rgba(130, 166, 255, 0.2);
  border-radius: 50%;
  font-size: 1.8rem;
  font-weight: 700;
}

.contact-avatar-sm {
  width: 2.35rem;
  height: 2.35rem;
  font-size: 0.9rem;
}

.contact-list-empty {
  display: flex;
  min-height: 12rem;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 1.5rem;
  text-align: center;
}

.contact-list-empty span {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.contact-search {
  position: relative;
  padding: 0.85rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.contact-search input {
  width: 100%;
  padding-left: 2.2rem;
  padding-right: 2rem;
  font-size: 0.9rem;
}

.search-icon {
  position: absolute;
  left: 1.6rem;
  top: 50%;
  z-index: 1;
  color: var(--text-muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.search-clear {
  position: absolute;
  right: 1.5rem;
  top: 50%;
  color: var(--text-muted);
  font-size: 1.25rem;
  text-decoration: none;
  transform: translateY(-50%);
}

.contact-detail {
  min-width: 0;
  border-left: 0;
  border-radius: 0 var(--radius) var(--radius) 0;
}

.contact-mobile-back {
  display: none;
}

.contact-detail-head {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 2rem;
  border-bottom: 1px solid var(--border);
}

.contact-heading {
  min-width: 0;
  flex: 1;
}

.contact-heading h2 {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 1.6rem;
}

.contact-heading p {
  margin: 0.35rem 0 0;
  color: var(--text-muted);
}

.contact-detail-body {
  display: grid;
  gap: 2rem;
  padding: 2rem;
}

.contact-field-group {
  display: grid;
  grid-template-columns: 7rem minmax(0, 1fr);
  gap: 1rem;
}

.contact-field-group h3 {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.contact-values {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.contact-values a {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  color: var(--accent-text);
  text-decoration: none;
}

.contact-values a:hover span {
  text-decoration: underline;
}

.contact-values small {
  color: var(--text-muted);
  font-size: 0.7rem;
  text-transform: uppercase;
}

.contact-facts {
  margin: 0;
}

.contact-facts div {
  display: grid;
  grid-template-columns: 6rem 1fr;
  gap: 1rem;
  padding-bottom: 0.65rem;
}

.contact-facts dt {
  color: var(--text-muted);
}

.contact-facts dd {
  margin: 0;
}

.contact-detail-empty {
  display: grid;
  min-height: 30rem;
  place-content: center;
  justify-items: center;
  padding: 2rem;
  text-align: center;
}

.contact-detail-empty h2 {
  margin: 1rem 0 0.25rem;
  font-size: 1.25rem;
}

.contact-detail-empty p {
  margin: 0 0 1.25rem;
  color: var(--text-muted);
}

.contact-empty-icon {
  display: grid;
  width: 3rem;
  height: 3rem;
  place-items: center;
  color: var(--accent-text);
  background: var(--accent-soft);
  border-radius: 50%;
}

.contact-editor {
  max-width: 48rem;
  margin: 0 auto;
}

.contact-editor-top {
  margin-bottom: 1.25rem;
}

.contact-editor-top h1 {
  margin-top: 1.25rem;
}

.contact-editor-top p {
  margin: 0.35rem 0 0;
  color: var(--text-muted);
}

.back-link {
  color: var(--text-muted);
  font-size: 0.875rem;
  text-decoration: none;
}

.back-link:hover {
  color: var(--text);
}

.contact-edit-form {
  padding: 1.5rem;
}

.contact-edit-form fieldset {
  margin: 0;
  padding: 0 0 1.5rem;
  border: 0;
}

.contact-edit-form fieldset + fieldset {
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.contact-edit-form legend,
.fieldset-heading h2 {
  margin: 0 0 1rem;
  padding: 0;
  font-size: 1rem;
  font-weight: 650;
}

.fieldset-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.fieldset-heading h2 {
  margin: 0;
}

.form-grid-two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.repeatable-fields {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.repeatable-field {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.repeatable-field input {
  min-width: 0;
  flex: 1;
}

.repeatable-field select {
  flex: 0 0 8.5rem;
  width: 8.5rem;
}

.contact-edit-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.action-spacer {
  flex: 1;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---- Tables ----------------------------------------------------------- */

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.table tbody tr:hover {
  background: var(--surface-2);
}

.table th {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.table td:last-child,
.table th:last-child {
  text-align: right;
}

.cell-sub {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--text-muted);
}

.field-list {
  list-style: none;
  margin: 0 0 0.35rem;
  padding: 0;
}

.field-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.15rem 0;
}

.field-list .tag {
  margin-left: 0.25rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 0.7rem;
}

.field-form {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.25rem;
}

.field-form input {
  min-width: 0;
  flex: 1;
  padding: 0.3rem 0.5rem;
  font-size: 0.85rem;
}

.icon-btn {
  border: 0;
  background: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.15rem 0.4rem;
}

.icon-btn:hover {
  color: var(--danger);
}

/* ---- Lists ------------------------------------------------------------ */

.list {
  display: flex;
  flex-direction: column;
}

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.list-row:last-child {
  border-bottom: 0;
}

.list-row .meta {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.list-row .muted {
  font-size: 0.85rem;
}

/* ---- Week calendar ---------------------------------------------------- */

.week-page {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.week-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
}

.week-heading h1 {
  margin: 0;
  font-size: 1.5rem;
}

.week-heading p {
  margin: 0.25rem 0 0;
  color: var(--text-muted);
}

.week-nav {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.week {
  overflow: hidden;
}

.week-hint {
  margin: 0;
  padding: 0.6rem 1rem;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.78rem;
  text-align: center;
}

.week-head,
.week-allday,
.week-grid {
  display: grid;
  grid-template-columns: 4.25rem repeat(7, minmax(6.5rem, 1fr));
}

.week-gutter {
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.week-allday .week-gutter {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0.5rem 0.6rem 0.5rem 0;
}

.week-day-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.85rem 0.5rem 0.7rem;
  border-left: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.week-day-label strong {
  color: var(--text);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
}

.week-day-label.is-today strong {
  display: grid;
  width: 2rem;
  height: 2rem;
  place-items: center;
  color: #fff;
  background: var(--accent);
  border-radius: 50%;
}

.week-allday {
  border-top: 1px solid var(--border);
  min-height: 2.75rem;
}

.week-allday-col {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-height: 2.75rem;
  padding: 0.4rem;
  border-left: 1px solid var(--border);
}

.week-allday-col.is-today,
.week-col.is-today {
  background: rgba(59, 111, 224, 0.05);
}

.week-chip {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  min-width: 0;
  padding: 0.2rem 0.35rem 0.2rem 0.5rem;
  color: var(--accent-text);
  background: var(--accent-soft);
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: grab;
  user-select: none;
}

.week-chip:active {
  cursor: grabbing;
}

.week-chip.is-rescheduling {
  opacity: 0.35;
}

.week-chip-ghost {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  min-width: 0;
  padding: 0.2rem 0.35rem 0.2rem 0.5rem;
  color: var(--accent-text);
  background: var(--accent-soft);
  border: 1px dashed var(--accent);
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  pointer-events: none;
  opacity: 0.85;
}

.week-chip span,
.week-event strong,
.week-event span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.week-chip .icon-btn,
.week-event .icon-btn {
  margin-left: auto;
  flex: 0 0 auto;
  opacity: 0;
}

.week-chip:hover .icon-btn,
.week-event:hover .icon-btn,
.week-chip:focus-within .icon-btn,
.week-event:focus-within .icon-btn {
  opacity: 1;
}

.week-scroll {
  overflow: auto;
  max-height: min(42rem, calc(100vh - 18rem));
  border-top: 1px solid var(--border);
}

.week-grid {
  position: relative;
  min-width: 56rem;
}

.week-hours {
  display: flex;
  flex-direction: column;
}

.week-hour {
  height: var(--hour-height);
  padding: 0 0.5rem;
  color: var(--text-muted);
  font-size: 0.7rem;
  line-height: 1;
  transform: translateY(-0.45em);
}

.week-col {
  position: relative;
  cursor: cell;
  border-left: 1px solid var(--border);
  background-image: repeating-linear-gradient(
    to bottom,
    transparent,
    transparent calc(var(--hour-height) - 1px),
    var(--border) calc(var(--hour-height) - 1px),
    var(--border) var(--hour-height)
  );
}

.week-event {
  position: absolute;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  overflow: hidden;
  padding: 0.25rem 0.4rem;
  color: var(--text);
  background: #1a2f5c;
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  cursor: grab;
  user-select: none;
}

.week-event:active {
  cursor: grabbing;
}

.week-event.is-rescheduling {
  opacity: 0.35;
}

.week-event strong {
  font-size: 0.8rem;
}

.week-event span {
  color: var(--accent-text);
  font-size: 0.7rem;
}

.week-event-location {
  color: var(--text-muted) !important;
}

.week-event-ghost {
  position: absolute;
  left: 2px;
  right: 2px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  overflow: hidden;
  padding: 0.25rem 0.4rem;
  color: var(--text);
  background: #254b8c;
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  cursor: grabbing;
}

.week-event-ghost strong {
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.week-event-ghost span {
  color: var(--accent-text);
  font-size: 0.7rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.week-now {
  position: absolute;
  right: 0;
  left: 0;
  z-index: 2;
  height: 2px;
  background: var(--danger);
  pointer-events: none;
}

.week-now::before {
  content: "";
  position: absolute;
  left: -5px;
  top: -4px;
  width: 10px;
  height: 10px;
  background: var(--danger);
  border-radius: 50%;
}

.week-selection {
  position: absolute;
  right: 2px;
  left: 2px;
  z-index: 3;
  overflow: hidden;
  padding: 0.15rem 0.35rem;
  color: var(--accent-text);
  background: var(--accent-soft);
  border: 1px dashed var(--accent);
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
}

/* ---- Modal ------------------------------------------------------------ */

.modal {
  width: min(28rem, calc(100vw - 2rem));
  padding: 0;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}

.modal::backdrop {
  background: rgba(5, 8, 13, 0.6);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.modal-head h2 {
  margin: 0;
  font-size: 1.1rem;
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.25rem;
}

.modal-when {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.modal-times {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}

/* ---- Status ----------------------------------------------------------- */

.empty {
  padding: 1.5rem;
  margin: 0;
  color: var(--text-muted);
  text-align: center;
  font-size: 0.95rem;
}

.muted {
  color: var(--text-muted);
}

.error {
  margin: 0;
  padding: 0.6rem 0.75rem;
  color: var(--danger);
  background: var(--danger-surface);
  border: 1px solid var(--danger-border);
  border-radius: 6px;
  font-size: 0.875rem;
}

.success {
  margin: 0;
  padding: 0.6rem 0.75rem;
  color: var(--success);
  background: var(--success-surface);
  border: 1px solid var(--success-border);
  border-radius: 6px;
  font-size: 0.875rem;
}

/* ---- Login page ------------------------------------------------------- */

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.login-form button {
  margin-top: 0.5rem;
}

/* SSO button above the password form ("or" divider between the two). */
.sso-button {
  display: block;
  width: 100%;
  padding: 0.7rem 1rem;
  margin-bottom: 0.75rem;
  text-align: center;
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  cursor: pointer;
}

.sso-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.sso-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0 0 1rem;
  color: var(--text-muted);
  font-size: 0.8125rem;
}

.sso-divider::before,
.sso-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.auth .card .error.msg {
  margin-bottom: 1rem;
}

/* ---- Sections --------------------------------------------------------- */

.section {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.section-title {
  margin: 0 0 0.25rem;
  font-size: 1.15rem;
}

.section-card {
  padding: 1.5rem;
}

/* ---- Profile (home) --------------------------------------------------- */

.profile {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 0;
  padding: 0.75rem 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.profile div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.profile dt {
  color: var(--text-muted);
  font-weight: 500;
}

.profile dd {
  margin: 0;
  word-break: break-all;
  text-align: right;
}

@media (max-width: 40rem) {
  .nav {
    flex-wrap: wrap;
    height: auto;
    padding: 0.5rem 1rem;
    gap: 0.5rem;
  }

  .nav-user {
    width: 100%;
    justify-content: flex-end;
    border-top: 1px solid var(--border);
    padding-top: 0.5rem;
  }

  .content {
    padding: 1rem;
  }

  .contacts-page {
    display: block;
  }

  .contacts-sidebar {
    min-height: calc(100vh - 8rem);
    border-radius: var(--radius);
  }

  .contact-detail {
    display: none;
  }

  .contacts-page:has(.contact-detail .contact-detail-head) .contacts-sidebar {
    display: none;
  }

  .contacts-page:has(.contact-detail .contact-detail-head) .contact-detail {
    display: block;
    border: 1px solid var(--border);
    border-radius: var(--radius);
  }

  .contact-detail-head {
    align-items: flex-start;
    flex-wrap: wrap;
    padding: 1.25rem;
  }

  .contact-mobile-back {
    display: grid;
    width: 2.25rem;
    height: 2.25rem;
    place-items: center;
    color: var(--text-muted);
    border-radius: 50%;
    text-decoration: none;
  }

  .contact-mobile-back:hover {
    color: var(--text);
    background: var(--surface-2);
  }

  .contact-detail-head .contact-avatar {
    width: 3.5rem;
    height: 3.5rem;
    font-size: 1.25rem;
  }

  .contact-detail-head .btn {
    width: 100%;
  }

  .contact-detail-body {
    padding: 1.25rem;
  }

  .contact-field-group {
    grid-template-columns: 1fr;
    gap: 0.6rem;
  }

  .form-grid-two {
    grid-template-columns: 1fr;
  }

  .repeatable-field {
    flex-wrap: wrap;
  }

  .repeatable-field select {
    flex: 1 1 8.5rem;
    width: auto;
  }

  .contact-edit-actions {
    flex-wrap: wrap;
  }

  .contact-edit-actions .action-spacer {
    display: none;
  }

  .contact-edit-actions .btn {
    flex: 1;
  }

  .contact-edit-actions .btn-danger {
    order: 3;
    min-width: 100%;
  }

  .week-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .week-nav {
    width: 100%;
  }

  .week-nav [data-new-event] {
    margin-left: auto;
  }

  .modal-times {
    grid-template-columns: 1fr;
  }

  .week-scroll {
    max-height: min(36rem, calc(100vh - 14rem));
  }
}

/* ---- Mail (Gmail-inspired) ------------------------------------------- */

.mail-page {
  display: grid;
  grid-template-columns: 16rem 1fr;
  gap: 1.25rem;
  align-items: start;
  min-height: calc(100vh - 8rem);
}

.mail-sidebar {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem 0.75rem;
}

.mail-compose-wrap {
  padding: 0.25rem 0.25rem 0.5rem;
}

.btn-compose {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.8rem 1.4rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 9999px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(59, 111, 224, 0.3);
  transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}

.btn-compose:hover {
  background: var(--accent-hover);
  box-shadow: 0 6px 16px rgba(59, 111, 224, 0.45);
  transform: translateY(-1px);
}

.compose-icon {
  flex-shrink: 0;
}

.mail-folders {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.mail-folder-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.9rem;
  border-radius: 9999px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}

.mail-folder-item:hover {
  background: var(--surface-2);
  color: var(--text);
}

.mail-folder-item.is-active {
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 600;
}

.mail-folder-icon {
  font-size: 1.1rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.mail-folder-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mail-badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  background: var(--accent);
  color: #fff;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.2;
}

.mail-total-count {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 500;
}

.mail-main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 38rem;
}

.mail-search-bar {
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.mail-search-form {
  position: relative;
  display: flex;
  align-items: center;
  max-width: 44rem;
}

.mail-search-form input[type="search"] {
  width: 100%;
  padding: 0.65rem 2.25rem 0.65rem 2.5rem;
  background: var(--field);
  border: 1px solid var(--border-strong);
  border-radius: 9999px;
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.mail-search-form input[type="search"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.mail-search-icon {
  position: absolute;
  left: 0.85rem;
  color: var(--text-muted);
  pointer-events: none;
  display: flex;
  align-items: center;
}

.mail-search-clear {
  position: absolute;
  right: 0.85rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}

.mail-search-clear:hover {
  color: var(--text);
}

.mail-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  min-height: 3rem;
}

.mail-toolbar-left,
.mail-toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.mail-select-all-label {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem;
  cursor: pointer;
}

.mail-toolbar-divider {
  width: 1px;
  height: 1.25rem;
  background: var(--border);
  margin: 0 0.25rem;
}

.mail-count-summary {
  color: var(--text-muted);
  font-size: 0.825rem;
  font-weight: 500;
}

.mail-toolbar-folder-tag {
  padding: 0.2rem 0.6rem;
  background: var(--surface-2);
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.mail-list {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.mail-row {
  display: flex;
  align-items: center;
  padding: 0.55rem 1rem;
  border-bottom: 1px solid var(--border);
  position: relative;
  transition: background 0.1s ease;
  user-select: none;
}

.mail-row:hover {
  background: rgba(255, 255, 255, 0.03);
}

.mail-row.is-unread {
  background: rgba(59, 111, 224, 0.06);
  box-shadow: inset 3px 0 var(--accent);
}

.mail-row-leading {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
  margin-right: 0.85rem;
}

.mail-row-check {
  width: 1.05rem;
  height: 1.05rem;
  cursor: pointer;
  accent-color: var(--accent);
}

.mail-star-btn {
  background: transparent;
  border: none;
  font-size: 1.25rem;
  line-height: 1;
  color: var(--border-strong);
  cursor: pointer;
  padding: 0.15rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, transform 0.1s;
}

.mail-star-btn:hover {
  color: #f5c518;
  transform: scale(1.15);
}

.mail-star-btn.is-starred {
  color: #f5c518;
}

.mail-row-main {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  text-decoration: none;
  color: inherit;
  gap: 1rem;
}

.mail-row-sender {
  width: 12rem;
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 500;
}

.mail-row.is-unread .mail-row-sender {
  font-weight: 700;
  color: var(--text);
}

.mail-row-content {
  display: flex;
  align-items: baseline;
  flex: 1;
  min-width: 0;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  gap: 0.4rem;
}

.mail-row-subject {
  flex-shrink: 0;
  max-width: 50%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
  font-weight: 400;
}

.mail-row.is-unread .mail-row-subject {
  font-weight: 700;
}

.mail-row-snippet {
  color: var(--text-muted);
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.mail-row-date {
  flex-shrink: 0;
  width: 5.5rem;
  text-align: right;
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.mail-row.is-unread .mail-row-date {
  font-weight: 700;
  color: var(--text);
}

.mail-row-actions {
  display: none;
  align-items: center;
  gap: 0.35rem;
  position: absolute;
  right: 1rem;
  background: var(--surface);
  padding-left: 0.5rem;
}

.mail-row:hover .mail-row-actions {
  display: flex;
}

.mail-row-action-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.35rem;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}

.mail-row-action-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.mail-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  text-align: center;
  gap: 0.5rem;
  color: var(--text-muted);
  flex: 1;
}

.mail-empty-icon {
  font-size: 3rem;
  margin-bottom: 0.5rem;
}

.mail-empty-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.mail-empty-subtext {
  font-size: 0.9rem;
  margin: 0;
}

/* Detail View */
.mail-detail-view {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 1.5rem;
  gap: 1.5rem;
}

.mail-detail-head {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1.25rem;
}

.mail-detail-title-line {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.mail-detail-title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
  word-break: break-word;
}

.mail-detail-box-badge {
  padding: 0.2rem 0.55rem;
  background: var(--surface-2);
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.mail-detail-sender-row {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.mail-avatar {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  background: var(--accent-soft);
  border: 1px solid rgba(130, 166, 255, 0.2);
  color: var(--accent-text);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.mail-detail-names {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.mail-detail-from {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem;
}

.mail-detail-author {
  font-size: 0.95rem;
  color: var(--text);
}

.mail-detail-email {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.mail-detail-to {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.mail-detail-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.mail-detail-time {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-right: 0.5rem;
}

.mail-detail-body {
  padding: 1rem 0;
  min-height: 12rem;
}

.mail-body-pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--text);
}

/* Sanitized HTML bodies render like other mail clients: constrained
   to the reading column, remote images capped, tables scrollable. */
.mail-body-html {
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--text);
  overflow-wrap: break-word;
  word-break: break-word;
}

/* Mail HTML universally assumes a light canvas (dark text, white cards).
   Our UI is dark, so the body gets its own light card like Gmail does —
   otherwise explicit dark colors render unreadably on our background. */
.mail-detail-body.is-html {
  background: #fff;
  color: #1d1d1f;
  color-scheme: light;
  border-radius: 10px;
  padding: 1rem 1.25rem;
}

.mail-detail-body.is-html .mail-body-html {
  color: #1d1d1f;
}

.mail-body-html img {
  max-width: 100%;
  height: auto;
}

.mail-body-html table {
  max-width: 100%;
}

.mail-body-html pre {
  white-space: pre-wrap;
}

.mail-body-html a {
  color: #0066cc;
}

.mail-detail-footer {
  border-top: 1px solid var(--border);
  padding-top: 1.5rem;
}

.mail-attachments {
  border-top: 1px solid var(--border);
  margin-top: 1rem;
  padding-top: 1rem;
}

.mail-attachments-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin: 0 0 0.5rem;
}

.mail-attachments-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.mail-attachment-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.mail-attachment-meta {
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* Invitation RSVP card, mirroring the Outlook invite header. */
.mail-rsvp {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.8rem 1rem;
  margin: 1rem 0;
  background: var(--surface);
}

.mail-rsvp-icon {
  font-size: 1.4rem;
}

.mail-rsvp-details {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  flex: 1 1 12rem;
}

.mail-rsvp-meta {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.mail-rsvp-added {
  color: #4caf7d;
  font-size: 0.85rem;
}

.mail-rsvp-actions {
  display: flex;
  gap: 0.4rem;
}

.mail-rsvp-add {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0.2rem 0;
  text-decoration: underline;
}

.btn-reply-dock {
  border: 1px solid var(--border-strong);
  border-radius: 9999px;
  padding: 0.55rem 1.25rem;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

/* Floating Compose Dock Window */
.compose-dock {
  position: fixed;
  bottom: 0;
  right: 2rem;
  width: 34rem;
  max-width: calc(100vw - 2rem);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 10px 10px 0 0;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.compose-dock[hidden] {
  display: none !important;
}

.compose-dock-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.compose-dock-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

.compose-control-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
}

.compose-control-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

.compose-dock-form {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.compose-error {
  padding: 0.5rem 1rem;
  background: var(--danger-surface);
  color: var(--danger);
  border-bottom: 1px solid var(--danger-border);
  font-size: 0.85rem;
}

.compose-dock-field {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding: 0.25rem 1rem;
}

.compose-field-label {
  width: 4.5rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
}

.compose-dock-field input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 0.925rem;
  padding: 0.5rem 0;
  outline: none;
}

.compose-dock-body {
  flex: 1;
  padding: 0.75rem 1rem;
  min-height: 12rem;
}

.compose-dock-body textarea {
  width: 100%;
  height: 100%;
  min-height: 13rem;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 0.925rem;
  font-family: inherit;
  line-height: 1.5;
  resize: none;
  outline: none;
}

.compose-dock-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.btn-send {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
  border: none;
  border-radius: 9999px;
  padding: 0.55rem 1.4rem;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-send:hover {
  background: var(--accent-hover);
}

.compose-discard-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.4rem;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
}

.compose-discard-btn:hover {
  color: var(--danger);
  background: var(--danger-surface);
}

@media (max-width: 768px) {
  .mail-page {
    grid-template-columns: 1fr;
  }

  .mail-page.is-reading .mail-sidebar {
    display: none;
  }

  .compose-dock {
    right: 0;
    width: 100%;
    border-radius: 0;
  }

  .mail-row-sender {
    width: 8rem;
  }

  .mail-row-subject {
    max-width: 100%;
  }

  .mail-row-snippet {
    display: none;
  }
}

/* ---- Profile Page ----------------------------------------------------- */

.profile-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  max-width: 56rem;
  margin: 0 auto;
}

.profile-header {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.profile-header h1 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
}

.profile-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 52rem) {
  .profile-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.profile-card {
  display: flex;
  flex-direction: column;
}

.profile-card .card-head h2 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
}

.profile-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.field-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
}

.profile-meta {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.75rem 0.875rem;
  background: var(--surface-2);
  border-radius: 6px;
  border: 1px solid var(--border);
}

.profile-meta-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
}

.profile-meta-value {
  font-size: 0.95rem;
  color: var(--text);
  font-weight: 500;
}

.profile-alert {
  padding: 0.6rem 0.75rem;
  border-radius: 6px;
  font-size: 0.875rem;
}

.profile-alert.success {
  color: var(--success);
  background: var(--success-surface);
  border: 1px solid var(--success-border);
}

.profile-alert.error {
  color: var(--danger);
  background: var(--danger-surface);
  border: 1px solid var(--danger-border);
}

input:disabled,
input[disabled],
input[readonly] {
  opacity: 0.7;
  cursor: not-allowed;
  background: var(--surface-2);
}

.nav-user-link {
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-user-link:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav-user-link[aria-current="page"] {
  color: var(--accent-text);
  background: var(--accent-soft);
  font-weight: 600;
}

/* ---- Notes & Lists --------------------------------------------------- */

.notes-page {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  max-width: 100%;
}

/* Quick-Add Container & Google Keep Style Card */
.notes-topbar {
  max-width: 38rem;
  width: 100%;
  margin: 0 auto;
  padding: 0.85rem 1.15rem 0.65rem 1.15rem;
  border-radius: 8px;
  background-color: var(--surface);
  border: 1px solid var(--border-strong);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25), 0 4px 14px rgba(0, 0, 0, 0.3);
  transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.notes-topbar:hover,
.notes-topbar:focus-within {
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.35), 0 8px 22px rgba(0, 0, 0, 0.45);
}

/* Dynamic background color preview via :has */
.notes-topbar:has(input[name="color"][value="coral"]:checked) { background-color: #3d1414; border-color: #5e1f1f; }
.notes-topbar:has(input[name="color"][value="peach"]:checked) { background-color: #3b2803; border-color: #5c3e04; }
.notes-topbar:has(input[name="color"][value="sand"]:checked) { background-color: #363202; border-color: #544d03; }
.notes-topbar:has(input[name="color"][value="mint"]:checked) { background-color: #122c0b; border-color: #1d4712; }
.notes-topbar:has(input[name="color"][value="sage"]:checked) { background-color: #0b2b24; border-color: #13473b; }
.notes-topbar:has(input[name="color"][value="fog"]:checked) { background-color: #062633; border-color: #0d4254; }
.notes-topbar:has(input[name="color"][value="storm"]:checked) { background-color: #0b1f42; border-color: #14356b; }
.notes-topbar:has(input[name="color"][value="blossom"]:checked) { background-color: #380d2b; border-color: #59163e; }
.notes-topbar:has(input[name="color"][value="clay"]:checked) { background-color: #2b1f14; border-color: #42311f; }

.notes-quickadd {
  display: flex;
  flex-direction: column;
}

.notes-quickadd-main {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.notes-input-title {
  background: transparent !important;
  border: none !important;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  padding: 0.25rem 0 !important;
  width: 100%;
}

.notes-input-title::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}

.notes-input-title:focus-visible {
  outline: none !important;
}

.notes-input-body {
  background: transparent !important;
  border: none !important;
  font-size: 0.95rem;
  color: var(--text);
  padding: 0.35rem 0 !important;
  resize: vertical;
  min-height: 3.5rem;
  line-height: 1.45;
  width: 100%;
}

.notes-input-body::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}

.notes-input-body:focus-visible {
  outline: none !important;
}

.notes-quickadd-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding-top: 0.65rem;
  margin-top: 0.4rem;
  border-top: 1px solid var(--border);
}

.notes-quickadd-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Mode Pills (Note / Checklist) */
.notes-kind-pills {
  display: inline-flex;
  background: var(--surface-2);
  padding: 2px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.notes-kind-pill {
  cursor: pointer;
  margin: 0;
  display: inline-flex;
}

.notes-kind-pill span {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  font-size: 0.8rem;
  font-weight: 500;
  border-radius: 4px;
  color: var(--text-muted);
  user-select: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.notes-kind-pill input:checked + span {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Color Swatches */
.notes-color-swatches {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-wrap: wrap;
}

.color-swatch {
  cursor: pointer;
  margin: 0;
  display: inline-flex;
  padding: 2px;
  border-radius: 50%;
  transition: transform 0.12s ease;
}

.color-swatch:hover {
  transform: scale(1.22);
}

.swatch-circle {
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 50%;
  display: block;
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.color-swatch input:checked + .swatch-circle {
  border-color: #fff;
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 3.5px var(--accent-text, #82a6ff);
}

.swatch-default .swatch-circle { background-color: var(--surface-2); border-color: var(--border-strong); }
.swatch-coral .swatch-circle { background-color: #5e1f1f; }
.swatch-peach .swatch-circle { background-color: #5c3e04; }
.swatch-sand .swatch-circle { background-color: #544d03; }
.swatch-mint .swatch-circle { background-color: #1d4712; }
.swatch-sage .swatch-circle { background-color: #13473b; }
.swatch-fog .swatch-circle { background-color: #0d4254; }
.swatch-storm .swatch-circle { background-color: #14356b; }
.swatch-blossom .swatch-circle { background-color: #59163e; }
.swatch-clay .swatch-circle { background-color: #42311f; }

.notes-save-btn {
  font-weight: 600;
  padding: 0.35rem 1rem;
}

/* Filter Banner */
.notes-filter-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
}

/* Notes Container & Sections */
.notes-container {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.notes-section-heading {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 0.5rem;
  margin-bottom: -0.75rem;
}

/* Notes Masonry/Grid */
.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(16.5rem, 1fr));
  gap: 1rem;
  align-items: start;
}

/* Note Card */
.note-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.15rem 0.65rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  position: relative;
  word-wrap: break-word;
}

.note-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.note-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.note-card-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.note-card-badges {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: -2px;
  margin-right: -4px;
}

/* Top-right Pin Button */
.note-pin-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--text-muted);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.25;
  transition: opacity 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.note-card:hover .note-pin-btn,
.note-pin-btn.is-pinned {
  opacity: 1;
}

.note-pin-btn.is-pinned {
  color: var(--accent-text, #82a6ff);
}

.note-pin-btn:hover {
  color: var(--text);
  transform: scale(1.15);
}

.note-card-body {
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--text);
  white-space: pre-wrap;
}

/* Checklist Styling */
.note-checklist {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.note-checkitem {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.note-checkitem-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
}

.note-checkitem input[type="checkbox"] {
  margin: 0;
  width: 15px;
  height: 15px;
  cursor: pointer;
  flex-shrink: 0;
  accent-color: var(--accent);
}

.note-item-text {
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.35;
}

.note-checkitem.completed .note-item-text {
  text-decoration: line-through;
  color: var(--text-muted);
  opacity: 0.65;
}

.note-additem-form {
  margin-top: 0.25rem;
  border-top: 1px dashed var(--border);
  padding-top: 0.45rem;
}

.note-input-additem {
  width: 100%;
  background: transparent !important;
  border: none !important;
  font-size: 0.85rem;
  padding: 0.2rem 0 !important;
  color: var(--text-muted);
}

.note-input-additem:focus-visible {
  outline: none !important;
  color: var(--text);
}

.note-item-del-form {
  margin: 0;
  width: auto !important;
}

.note-item-del {
  padding: 0 0.35rem;
  font-size: 1.1rem;
  line-height: 1;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text-muted);
  opacity: 0.2;
  transition: opacity 0.15s ease, color 0.15s ease;
}

.note-checkitem:hover .note-item-del {
  opacity: 0.7;
}

.note-item-del:hover {
  opacity: 1 !important;
  color: var(--danger);
}

.note-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.25rem;
}

.note-tag-chip {
  font-size: 0.72rem;
  color: var(--accent-text);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.08);
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  transition: background 0.15s ease;
}

.note-tag-chip:hover {
  background: rgba(255, 255, 255, 0.16);
}

/* Edit Form */
.note-edit-details {
  margin-top: 0.25rem;
}

.note-edit-summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  background: transparent;
  transition: background 0.15s ease, color 0.15s ease;
}

.note-edit-summary:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.note-edit-summary::-webkit-details-marker {
  display: none;
}

.note-edit-form {
  margin-top: 0.5rem;
  padding: 0.65rem;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.notes-edit-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Footer Actions */
.note-card-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
  margin-top: auto;
  padding-top: 0.4rem;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.note-card:hover .note-card-foot,
.note-card:focus-within .note-card-foot {
  opacity: 1;
}

@media (max-width: 768px) {
  .note-card-foot,
  .note-pin-btn {
    opacity: 1 !important;
  }
}

.note-foot-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 0.78rem;
  color: var(--text-muted);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  transition: background 0.15s ease, color 0.15s ease;
}

.note-foot-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

.note-foot-del:hover {
  color: var(--danger);
  background: var(--danger-surface);
}

/* Pinned border/indicator */
.note-pinned {
  border-color: var(--accent);
}

/* Empty State */
.notes-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 5rem 1.5rem;
  text-align: center;
  width: 100%;
  color: var(--text-muted);
}

.notes-empty-icon {
  margin-bottom: 1.25rem;
  opacity: 0.25;
  color: var(--text-muted);
  display: flex;
  justify-content: center;
}

.notes-empty-title {
  font-size: 1.35rem;
  font-weight: 500;
  color: var(--text-muted);
  margin: 0 0 0.5rem 0;
}

.notes-empty-subtext {
  font-size: 0.95rem;
  color: var(--text-muted);
  opacity: 0.7;
  max-width: 26rem;
  margin: 0;
  line-height: 1.5;
}

/* Pastel Theme Backgrounds (Dark Mode Soft Tints) */
.note-color-coral {
  background-color: #3d1414;
  border-color: #5e1f1f;
}
.note-color-peach {
  background-color: #3b2803;
  border-color: #5c3e04;
}
.note-color-sand {
  background-color: #363202;
  border-color: #544d03;
}
.note-color-mint {
  background-color: #122c0b;
  border-color: #1d4712;
}
.note-color-sage {
  background-color: #0b2b24;
  border-color: #13473b;
}
.note-color-fog {
  background-color: #062633;
  border-color: #0d4254;
}
.note-color-storm {
  background-color: #0b1f42;
  border-color: #14356b;
}
.note-color-blossom {
  background-color: #380d2b;
  border-color: #59163e;
}
.note-color-clay {
  background-color: #2b1f14;
  border-color: #42311f;
}

/* ---- Settings Page --------------------------------------------------- */

.settings-page {
  display: grid;
  grid-template-columns: 18rem 1fr;
  gap: 1.25rem;
  align-items: start;
  min-height: calc(100vh - 8rem);
}

.settings-sidebar {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1rem 0.75rem;
}

.settings-nav-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.settings-nav-group-title {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 0.5rem 0.75rem 0.25rem;
  text-transform: uppercase;
}

.settings-nav-divider {
  border-top: 1px solid var(--border);
  margin: 0.5rem 0;
}

.settings-nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}

.settings-nav-item:hover {
  background: var(--surface-2);
}

.settings-nav-item.is-active {
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 600;
}

.settings-nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
}

.settings-main {
  padding: 1.5rem;
}

.settings-header {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.settings-header h2 {
  margin: 0 0 0.25rem;
  font-size: 1.5rem;
  font-weight: 700;
}

.settings-header .subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.settings-alert {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

.settings-alert.success {
  background: var(--success-surface);
  border: 1px solid var(--success-border);
  color: var(--success);
}

.settings-alert.error {
  background: var(--danger-surface);
  border: 1px solid var(--danger-border);
  color: var(--danger);
}

@media (max-width: 768px) {
  .settings-page {
    grid-template-columns: 1fr;
  }
}