:root {
  --dm-bg: #f7f8fa;
  --dm-surface: #ffffff;
  --dm-text: #1a1d26;
  --dm-muted: #6b7280;
  --dm-accent: #c59443;
  --dm-accent-pressed: #a87a32;
  --dm-on-accent: #ffffff;
  --dm-primary-surface: #f7f0e4;
  --dm-border: #e5e7eb;
  --dm-free: #059669;
  --dm-busy: #d97706;
  --dm-error: #dc2626;
  --dm-radius: 12px;
  --dm-max: 720px;
  --dm-pad: 16px;
}

html[data-theme="dark"] {
  --dm-bg: #12161a;
  --dm-surface: #1c2228;
  --dm-text: #ffffff;
  --dm-muted: #a0a8b0;
  --dm-accent: #c59443;
  --dm-accent-pressed: #a87a32;
  --dm-on-accent: #ffffff;
  --dm-primary-surface: #2a2418;
  --dm-border: #2a323a;
  --dm-free: #00a843;
  --dm-busy: #d97706;
  --dm-error: #e55039;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body.dm-body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--dm-bg);
  color: var(--dm-text);
  line-height: 1.5;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--dm-accent);
}

.dm-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 8px var(--dm-pad);
  background: var(--dm-surface);
  border-bottom: 1px solid var(--dm-border);
}

.dm-brand {
  font-weight: 700;
  font-size: 18px;
  color: var(--dm-accent);
  text-decoration: none;
  white-space: nowrap;
}

.dm-nav {
  display: flex;
  gap: 4px;
  flex: 1;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.dm-nav a {
  flex-shrink: 0;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--dm-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
}

.dm-nav a.is-active,
.dm-nav a:hover {
  color: var(--dm-text);
  background: var(--dm-primary-surface);
}

.dm-topbar .theme-toggle {
  flex-shrink: 0;
}

.dm-main {
  flex: 1;
  width: 100%;
  max-width: var(--dm-max);
  margin: 0 auto;
  padding: 20px var(--dm-pad) 40px;
}

.dm-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  padding: 16px;
  color: var(--dm-muted);
  font-size: 13px;
  border-top: 1px solid var(--dm-border);
}

.dm-footer a {
  color: var(--dm-muted);
  text-decoration: none;
}

.dm-page-head h1,
.dm-detail h1,
.dm-form-page h1 {
  margin: 0 0 8px;
  font-size: 28px;
  line-height: 1.2;
}

.dm-lead {
  margin: 0 0 16px;
  color: var(--dm-muted);
  font-size: 15px;
}

.dm-back {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-bottom: 8px;
  color: var(--dm-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
}

.dm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 12px 18px;
  border: none;
  border-radius: var(--dm-radius);
  font-size: 16px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  font-family: inherit;
}

.dm-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.dm-btn-primary {
  background: var(--dm-accent);
  color: var(--dm-on-accent);
}

.dm-btn-primary:hover:not(:disabled) {
  background: var(--dm-accent-pressed);
}

.dm-btn-secondary {
  background: var(--dm-primary-surface);
  color: var(--dm-text);
}

.dm-btn-block {
  width: 100%;
}

.dm-filters {
  display: grid;
  gap: 12px;
  margin: 20px 0 24px;
  padding: 16px;
  background: var(--dm-surface);
  border: 1px solid var(--dm-border);
  border-radius: var(--dm-radius);
}

.dm-field {
  display: grid;
  gap: 6px;
}

.dm-field > span {
  font-size: 13px;
  font-weight: 600;
  color: var(--dm-muted);
}

.dm-field input,
.dm-field select,
.dm-field textarea {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--dm-border);
  border-radius: 10px;
  background: var(--dm-surface);
  color: var(--dm-text);
  font: inherit;
  font-size: 16px;
}

.dm-field textarea {
  min-height: 120px;
  resize: vertical;
}

.dm-field-hint {
  margin: 0;
  font-size: 13px;
  color: var(--dm-muted);
}

.dm-master-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.dm-master-card {
  display: flex;
  gap: 14px;
  padding: 14px;
  background: var(--dm-surface);
  border: 1px solid var(--dm-border);
  border-radius: var(--dm-radius);
  text-decoration: none;
  color: inherit;
}

.dm-master-card:hover {
  border-color: var(--dm-accent);
}

.dm-avatar {
  flex-shrink: 0;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--dm-primary-surface);
  color: var(--dm-accent);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 18px;
}

.dm-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.dm-avatar-lg {
  width: 96px;
  height: 96px;
  font-size: 28px;
}

.dm-master-body {
  flex: 1;
  min-width: 0;
}

.dm-master-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.dm-master-row strong {
  font-size: 16px;
}

.dm-meta {
  margin: 4px 0 0;
  color: var(--dm-muted);
  font-size: 13px;
}

.dm-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.dm-badge-free {
  background: rgba(5, 150, 105, 0.12);
  color: var(--dm-free);
}

.dm-badge-busy {
  background: rgba(217, 119, 6, 0.12);
  color: var(--dm-busy);
}

.dm-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.dm-chip {
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--dm-primary-surface);
  color: var(--dm-text);
  font-size: 12px;
  font-weight: 600;
}

.dm-chip-toggle {
  border: 1px solid var(--dm-border);
  background: var(--dm-surface);
  cursor: pointer;
  font: inherit;
  min-height: 36px;
}

.dm-chip-toggle.is-selected {
  border-color: var(--dm-accent);
  background: var(--dm-primary-surface);
  color: var(--dm-text);
}

.dm-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--dm-muted);
}

.dm-empty-page h1 {
  margin-bottom: 8px;
  font-size: 22px;
  color: var(--dm-text);
}

.dm-link {
  color: var(--dm-accent);
  font-weight: 600;
}

.dm-detail-head {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 24px;
}

.dm-section {
  margin-bottom: 24px;
}

.dm-section h2 {
  margin: 0 0 10px;
  font-size: 17px;
}

.dm-about {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.dm-portfolio {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.dm-portfolio-item {
  margin: 0;
  background: var(--dm-surface);
  border: 1px solid var(--dm-border);
  border-radius: 10px;
  overflow: hidden;
}

.dm-portfolio-item img {
  aspect-ratio: 1;
  width: 100%;
  object-fit: cover;
}

.dm-portfolio-item figcaption {
  padding: 8px 10px;
  font-size: 12px;
  color: var(--dm-muted);
}

.dm-cta-stack {
  display: grid;
  gap: 10px;
  margin-top: 8px;
}

.dm-form {
  display: grid;
  gap: 16px;
}

.dm-phone-row {
  display: grid;
  grid-template-columns: minmax(120px, 140px) 1fr;
  gap: 10px;
}

.dm-error-text {
  margin: 0;
  color: var(--dm-error);
  font-size: 14px;
}

.dm-success-box {
  padding: 16px;
  border-radius: var(--dm-radius);
  background: rgba(5, 150, 105, 0.12);
  color: var(--dm-free);
}

.dm-provider-banner {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px;
  margin-bottom: 16px;
  background: var(--dm-surface);
  border: 1px solid var(--dm-border);
  border-radius: var(--dm-radius);
}

.dm-provider-banner .dm-avatar {
  width: 48px;
  height: 48px;
  font-size: 14px;
}

.dm-hidden {
  display: none !important;
}

.dm-service-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

@media (min-width: 640px) {
  .dm-filters {
    grid-template-columns: 1fr 1fr auto;
    align-items: end;
  }

  .dm-portfolio {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .dm-cta-stack {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 768px) {
  .dm-main {
    padding-top: 28px;
  }
}
