:root {
  --bg: #24180f;
  --bg-2: #302015;
  --panel: #3b281d;
  --panel-2: #493222;
  --line: #62452f;
  --text: #f0e4c9;
  --muted: #c0aa91;
  --brand: #e3ad3e;
  --ok: #76b77e;
  --danger: #d56c53;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Avenir Next", Avenir, "Trebuchet MS", sans-serif;
  background-color: var(--bg);
  background-image:
    linear-gradient(rgba(227, 173, 62, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(227, 173, 62, 0.02) 1px, transparent 1px),
    radial-gradient(ellipse at top right, #452b1c 0%, transparent 48%);
  background-size: 48px 48px, 48px 48px, auto;
  background-attachment: fixed;
  color: var(--text);
}

a {
  color: inherit;
}

.app-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  display: flex;
  width: 68px;
  flex-direction: column;
  align-items: center;
  border-right: 1px solid rgba(223, 132, 63, 0.14);
  background: rgba(32, 21, 14, 0.96);
  padding: 12px 8px;
}

.app-sidebar-brand,
.app-sidebar-link {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 11px;
  color: #b69a7b;
  text-decoration: none;
}

.app-sidebar-brand {
  border: 1px solid rgba(227, 173, 62, 0.58);
  background: #3b291d;
  color: var(--brand);
  font-size: 21px;
  font-weight: 800;
}

.app-sidebar-nav {
  display: grid;
  gap: 8px;
  margin-top: 20px;
}

.app-sidebar-link svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.app-sidebar-link:hover,
.app-sidebar-link:focus-visible,
.app-sidebar-link.is-active {
  outline: none;
  background: #4a3020;
  color: var(--brand);
}

.app-sidebar-link.is-active::before {
  position: absolute;
  left: 0;
  width: 3px;
  height: 26px;
  border-radius: 0 3px 3px 0;
  background: var(--brand);
  content: "";
}

.app-sidebar-status {
  display: grid;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  place-items: center;
  margin-top: auto;
  border: 1px solid rgba(240, 228, 201, 0.28);
  border-radius: 50%;
  background: #d9a957;
  color: #382619;
  font-size: 10px;
  font-weight: 800;
}

body.has-app-sidebar {
  padding-left: 68px;
}

.has-app-sidebar .floating-panel,
.has-app-sidebar .bottom-bar {
  left: 80px;
}

@media (max-width: 620px) {
  body.has-app-sidebar {
    padding-left: 0;
  }

  .app-sidebar {
    inset: auto 0 0;
    width: 100%;
    height: calc(62px + env(safe-area-inset-bottom));
    flex-direction: row;
    justify-content: center;
    border-top: 1px solid rgba(223, 132, 63, 0.22);
    border-right: 0;
    padding: 5px 8px env(safe-area-inset-bottom);
  }

  .app-sidebar-brand,
  .app-sidebar-status {
    display: none;
  }

  .app-sidebar-nav {
    display: flex;
    width: min(100%, 440px);
    justify-content: space-between;
    gap: 2px;
    margin: 0;
  }

  .app-sidebar-link {
    width: 44px;
    height: 44px;
  }

  .app-sidebar-link.is-active::before {
    top: 0;
    left: auto;
    width: 24px;
    height: 3px;
    border-radius: 0 0 3px 3px;
  }

  .has-app-sidebar .floating-panel,
  .has-app-sidebar .bottom-bar {
    right: 8px;
    bottom: calc(70px + env(safe-area-inset-bottom));
    left: 8px;
  }
}

.page-shell {
  max-width: 980px;
  margin: 0 auto;
  padding: 14px 14px 110px;
}

.page-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.page-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  font-size: 0.95rem;
  color: var(--muted);
  padding: 8px 2px;
}

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

.page-logo {
  width: 112px;
  max-width: 40vw;
  height: auto;
}

.page-title {
  margin: 0 0 8px;
  font-size: clamp(1.2rem, 3.5vw, 1.8rem);
  letter-spacing: 0.02em;
}

.page-subtitle {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.96rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.sync-status {
  align-self: center;
  color: var(--muted);
  font-size: 0.82rem;
}

.sync-status[data-state="success"] {
  color: #6ee7b7;
}

.sync-status[data-state="error"] {
  color: #fbbf24;
}

.input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #302116;
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  font: inherit;
}

.input::placeholder,
textarea::placeholder {
  color: #7b8ba1;
}

label {
  display: block;
  margin: 0 0 6px;
  font-size: 0.87rem;
  color: var(--muted);
}

.grid {
  display: grid;
  gap: 10px;
}

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

@media (min-width: 760px) {
  .grid.two {
    grid-template-columns: 1fr 1fr;
  }
}

.card {
  background: linear-gradient(160deg, var(--panel), var(--panel-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
}

.card h3 {
  margin: 0 0 8px;
  font-size: 1.05rem;
}

.contact-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.contact-channels {
  display: grid;
  gap: 3px;
}

.contact-channels a {
  overflow: hidden;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.contact-channels a:hover {
  color: var(--text);
}

.contact-note {
  margin: 6px 0 0;
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
}

.meta {
  font-size: 0.83rem;
  color: var(--muted);
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  padding: 3px 9px;
  font-size: 0.78rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.btn {
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #493222;
  color: var(--text);
  padding: 9px 12px;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
}

.btn:hover {
  border-color: #64748b;
}

.btn.primary {
  background: linear-gradient(140deg, #e9bc59, #d68f37);
  color: #302015;
  border-color: transparent;
}

.btn.success {
  background: rgba(16, 185, 129, 0.18);
  border-color: rgba(16, 185, 129, 0.5);
}

.btn.danger {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.5);
}

@media (max-width: 759px) {
  .contact-list {
    gap: 6px;
  }

  .contact-list .contact-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: var(--radius-sm);
    box-shadow: none;
  }

  .contact-list .contact-heading {
    margin-bottom: 3px;
  }

  .contact-list .pill {
    padding: 2px 6px;
    font-size: 0.7rem;
  }

  .contact-list .contact-card h3 {
    margin-bottom: 3px;
    font-size: 0.95rem;
  }

  .contact-list .contact-channels {
    display: flex;
    gap: 8px;
    max-width: 100%;
  }

  .contact-list .contact-channels a {
    max-width: 52%;
    font-size: 0.76rem;
  }

  .contact-list .contact-note {
    display: none;
  }

  .contact-list .contact-actions {
    display: grid;
    gap: 5px;
    margin: 0;
  }

  .contact-list .contact-actions .btn {
    padding: 6px 8px;
    font-size: 0.72rem;
  }
}

.floating-panel {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #302116f2;
  backdrop-filter: blur(8px);
  padding: 10px;
  z-index: 20;
}

.form-toggle {
  width: 100%;
}

.floating-panel .form-toggle + form {
  margin-top: 10px;
}

.empty {
  text-align: center;
  padding: 20px 10px;
  color: var(--muted);
}

.tag {
  display: inline-flex;
  align-items: center;
  border-radius: 8px;
  padding: 2px 7px;
  margin-right: 4px;
  margin-bottom: 4px;
  background: rgba(227, 173, 62, 0.18);
  color: #f0c565;
  font-size: 0.76rem;
}

.check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.check-item.dragging {
  opacity: 0.45;
}

.check-item.drag-over-after {
  border-bottom: 2px solid var(--brand);
}

.drag-handle {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: grab;
  font: inherit;
  font-weight: 700;
  padding: 10px 5px;
  touch-action: none;
}

.drag-handle:active {
  cursor: grabbing;
}

.task-edit {
  padding: 6px 8px;
  font-size: 0.8rem;
}

.check-item:last-child {
  border-bottom: none;
}

.check-item.done span {
  text-decoration: line-through;
  color: var(--muted);
}

.check-item.not-due-today {
  opacity: 0.48;
}

.check-item.not-due-today:hover,
.check-item.not-due-today:focus-within {
  opacity: 0.78;
}

.weekday-select {
  flex: 0 0 118px;
  width: 118px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #302116;
  color: var(--muted);
  padding: 6px;
  font: inherit;
  font-size: 0.78rem;
}

@media (max-width: 520px) {
  .check-item {
    flex-wrap: wrap;
  }

  .check-item > span[style] {
    min-width: 0;
  }

  .weekday-select {
    order: 5;
    flex-basis: calc(100% - 38px);
    width: calc(100% - 38px);
    margin-left: 38px;
  }
}

.check-item input[type="checkbox"] {
  transform: scale(1.25);
}

.signature-area {
  margin-top: 12px;
}

.signature-canvas {
  display: block;
  width: 100%;
  height: 150px;
  border: 1px dashed #64748b;
  border-radius: var(--radius-sm);
  background: #302116;
  touch-action: none;
}

.signature-status {
  margin-top: 10px;
  color: #6ee7b7;
  font-size: 0.85rem;
}

.signature-preview {
  display: block;
  width: 100%;
  height: 90px;
  margin-top: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #302116;
  object-fit: contain;
}

.archive-section {
  margin-top: 28px;
}

.archive-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.archive-heading h2 {
  margin: 0;
  font-size: 1.15rem;
}

.archive-entry {
  padding: 0;
  overflow: hidden;
}

.archive-entry summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  padding: 12px;
  font-weight: 600;
}

.archive-entry summary::marker {
  color: var(--brand);
}

.archive-tasks,
.archive-entry .signature-status,
.archive-entry .signature-preview {
  margin-left: 12px;
  margin-right: 12px;
}

.archive-entry .signature-preview {
  width: calc(100% - 24px);
  margin-bottom: 12px;
}
