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

:root {
  --primary: #1a73e8;
  --primary-dark: #1557b0;
  --primary-soft: #e8f0fe;
  --danger: #d93025;
  --danger-dark: #b3261e;
  --danger-soft: #fce8e6;
  --success: #188038;
  --success-soft: #e6f4ea;
  --warning: #f9ab00;
  --bg: #f8f9fa;
  --surface: #ffffff;
  --text: #202124;
  --text-secondary: #5f6368;
  --border: #dadce0;
  --radius: 16px;
  --radius-sm: 12px;
  --radius-xs: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.15);
  --shadow-xl: 0 10px 30px rgba(0,0,0,0.2);
}

html[data-theme="dark"] {
  --bg: #121212;
  --surface: #1e1e1e;
  --text: #e8eaed;
  --text-secondary: #9aa0a6;
  --border: #3c4043;
  --primary: #8ab4f8;
  --primary-dark: #aecbfa;
  --primary-soft: rgba(138,180,248,0.15);
  --danger: #f28b82;
  --danger-dark: #f6aea9;
  --danger-soft: rgba(242,139,130,0.15);
  --success: #81c995;
  --success-soft: rgba(129,201,149,0.15);
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-xl: 0 10px 30px rgba(0,0,0,0.5);
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    --bg: #121212;
    --surface: #1e1e1e;
    --text: #e8eaed;
    --text-secondary: #9aa0a6;
    --border: #3c4043;
    --primary: #8ab4f8;
    --primary-dark: #aecbfa;
    --primary-soft: rgba(138,180,248,0.15);
    --danger: #f28b82;
    --danger-dark: #f6aea9;
    --danger-soft: rgba(242,139,130,0.15);
    --success: #81c995;
    --success-soft: rgba(129,201,149,0.15);
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-xl: 0 10px 30px rgba(0,0,0,0.5);
  }
}

html {
  height: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

header {
  background: var(--primary);
  color: white;
  padding: 14px 12px;
  padding-top: calc(14px + env(safe-area-inset-top));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: var(--shadow);
}

header h1 {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.2;
  margin: 0;
  text-align: center;
}

.header-left,
.header-actions {
  flex: 0 0 44px;
  display: flex;
  align-items: center;
}

.header-actions {
  justify-content: flex-end;
}

.header-center {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  gap: 4px;
}

.header-site-select {
  appearance: none;
  -webkit-appearance: none;
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: var(--radius-xs);
  padding: 4px 28px 4px 12px;
  font-size: 0.85rem;
  font-weight: 500;
  font-family: inherit;
  min-width: 140px;
  max-width: 80vw;
  text-align: center;
  text-align-last: center;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M7 10l5 5 5-5H7z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 18px;
}

.header-site-select option {
  background: var(--surface);
  color: var(--text);
  text-align: left;
}

.header-site-select:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.8);
}

.header-site-select.hidden {
  display: none;
}

.header-meta {
  font-size: 0.75rem;
  opacity: 0.9;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.http-warning {
  font-size: 0.7rem;
  color: #ffeb3b;
  margin-top: 2px;
  font-weight: 500;
}

.btn-header-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  color: white;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
  flex-shrink: 0;
}

.btn-header-chip:active {
  transform: scale(0.96);
  background: rgba(255,255,255,0.25);
}

.btn-header-chip:disabled {
  opacity: 0.7;
  cursor: wait;
}

.menu-icon {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.header-label {
  display: none;
}

@media (min-width: 360px) {
  .header-label {
    display: inline;
  }
}

main {
  max-width: 680px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: 40px;
}

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

.section-separated {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.2s, opacity 0.2s, background 0.2s;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.45;
  pointer-events: none;
}

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: var(--shadow);
}

.btn-primary:not(:disabled):active {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--surface);
  color: var(--primary);
  border: 2px solid var(--primary);
  box-shadow: var(--shadow);
}

.btn-danger {
  background: var(--danger);
  color: white;
  box-shadow: var(--shadow);
}

.btn-danger:not(:disabled):active {
  background: var(--danger-dark);
}

.btn-success {
  background: #34a853;
  color: white;
  box-shadow: var(--shadow);
}

.btn-success:not(:disabled):active {
  filter: brightness(0.9);
}

.btn-small {
  padding: 8px 16px;
  font-size: 0.85rem;
  border-radius: var(--radius-xs);
}

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.sync-actions .btn-small {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.btn-outline-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}

.filter-select {
  -webkit-appearance: none;
  appearance: none;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 8px 32px 8px 12px;
  font-size: 0.85rem;
  font-family: inherit;
  line-height: 1.3;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%235f6368'%3E%3Cpath d='M7 10l5 5 5-5H7z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 18px;
  cursor: pointer;
}

.filter-select:focus {
  outline: none;
  border-color: var(--primary);
}

#form-section {
  margin-bottom: 8px;
}

.day-blocked-banner {
  background: var(--warning);
  color: #202124;
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.day-blocked-banner strong {
  display: block;
  font-size: 1rem;
  margin-bottom: 4px;
}

.day-blocked-banner p {
  font-size: 0.9rem;
  line-height: 1.4;
}

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.checkbox-group .chip {
  flex: 1 1 auto;
  min-width: 90px;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  font-weight: 500;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.1s;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

.checkbox-group .chip:active {
  transform: scale(0.97);
}

.checkbox-group .chip.selected {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-weight: 600;
}

option:disabled {
  color: #9aa0a6;
  background-color: #f1f3f4;
  font-style: italic;
}

#tagesdaten-info {
  background: var(--success-soft);
  color: var(--success);
}

#tagesdaten-info strong {
  color: var(--success);
}

.image-placeholder.small {
  aspect-ratio: 16 / 10;
  min-height: 140px;
  max-height: 220px;
}

.image-placeholder.small .camera-icon {
  width: 36px;
  height: 36px;
}

.image-placeholder.small .placeholder-content span {
  font-size: 0.95rem;
}

.image-placeholder.small .placeholder-content small {
  font-size: 0.75rem;
}

.btn-close-day {
  width: 100%;
  margin-top: 16px;
  background: #34a853;
  color: white;
  border: none;
}

.btn-close-day:not(:disabled):active {
  background: #2e8f47;
}

.image-placeholder {
  width: 100%;
  aspect-ratio: 16/9;
  min-height: 160px;
  background: var(--primary-soft);
  border: 2px dashed var(--primary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  overflow: hidden;
  position: relative;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  margin-bottom: 20px;
}

.image-placeholder:active {
  transform: scale(0.99);
  background: #d2e3fc;
}

.image-placeholder.has-image {
  border-style: solid;
  border-color: transparent;
}

.image-placeholder.has-image .placeholder-content {
  display: none;
}

.placeholder-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  padding: 16px;
}

.placeholder-content span {
  font-weight: 600;
  font-size: 1rem;
}

.placeholder-content small {
  color: var(--text-secondary);
  font-size: 0.8rem;
}

.camera-icon {
  width: 48px;
  height: 48px;
  fill: currentColor;
  opacity: 0.8;
}

.image-placeholder img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: absolute;
  inset: 0;
  display: block;
  z-index: 1;
}

.field {
  margin-bottom: 18px;
}

.field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1.05rem;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.2s;
  -webkit-appearance: none;
  appearance: none;
}

.field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%235f6368'%3E%3Cpath d='M7 10l5 5 5-5H7z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 24px;
  padding-right: 44px;
}

.field input[type="time"],
.field input[type="number"] {
  padding-right: 16px;
}

.field select:disabled,
.field input:disabled,
.field textarea:disabled {
  background-color: #f1f3f4;
  color: #9aa0a6;
  opacity: 0.8;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: var(--primary);
}

.sector-group {
  display: flex;
  align-items: stretch;
  gap: 8px;
  flex-wrap: nowrap;
}

.sector-group .btn-sector-map,
.sector-group select,
.sector-group input[type="number"] {
  height: 48px;
  min-height: 48px;
  max-height: 48px;
  box-sizing: border-box;
}

.btn-sector-map {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  min-width: 48px;
  padding: 0;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--primary);
  cursor: pointer;
  transition: transform 0.1s, border-color 0.2s, background 0.2s;
  flex: 0 0 48px;
}

.btn-sector-map svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.btn-sector-map:active {
  transform: scale(0.96);
}

.btn-sector-map:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.sector-pair {
  display: flex;
  align-items: stretch;
  gap: 6px;
  flex: 1 1 0;
  min-width: 0;
}

.sector-pair select {
  flex: 0 0 48px;
  width: 48px;
  min-width: 48px;
  padding: 0 18px 0 6px;
  background-position: right 4px center;
  background-size: 14px;
  text-align: center;
  text-align-last: center;
}

.sector-pair input[type="number"] {
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
  padding: 0 6px;
  text-align: center;
}

@media (max-width: 360px) {
  .sector-group {
    gap: 6px;
  }

  .sector-group .btn-sector-map,
  .sector-group select,
  .sector-group input[type="number"] {
    height: 44px;
    min-height: 44px;
    max-height: 44px;
  }

  .btn-sector-map {
    width: 44px;
    min-width: 44px;
    flex: 0 0 44px;
  }

  .sector-pair select {
    flex: 0 0 40px;
    width: 40px;
    min-width: 40px;
  }
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.chip {
  flex: 1 1 auto;
  min-width: 90px;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  font-weight: 500;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.1s;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

.chip:active {
  transform: scale(0.97);
}

.chip.selected {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-weight: 600;
}

#desc-wrapper {
  position: relative;
}

#desc-wrapper textarea {
  padding-right: 56px;
  resize: vertical;
  min-height: 90px;
}

#btn-dictate {
  position: absolute;
  bottom: 8px;
  right: 8px;
}

.btn-icon {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s, background 0.2s;
  flex-shrink: 0;
}

.btn-icon svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.btn-icon:active {
  transform: scale(0.9);
}

.btn-icon:disabled {
  opacity: 0.3;
  pointer-events: none;
}

.btn-icon.listening {
  background: var(--danger);
  animation: pulse 1.2s infinite;
}

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

#dictation-status {
  font-size: 0.85rem;
  font-weight: 500;
  margin-top: 6px;
  margin-bottom: 4px;
  padding: 8px 12px;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--primary-dark);
  background: var(--primary-soft);
}

#dictation-status::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  animation: pulse 1.2s infinite;
}

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

.actions-stacked {
  flex-direction: column;
  gap: 16px;
}

.actions-stacked #btn-save {
  margin-top: 8px;
}

.actions .btn {
  width: 100%;
}
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.hidden {
  display: none !important;
}

#records-section h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0;
  color: var(--text);
  line-height: 1.2;
}

#records-section .records-header {
  margin-bottom: 16px;
}

#records-section .records-header h2 {
  margin-bottom: 0;
}

.empty-state {
  text-align: center;
  color: var(--text-secondary);
  padding: 40px 16px;
  font-size: 0.95rem;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.record-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  overflow: hidden;
  transition: box-shadow 0.2s, transform 0.1s;
}

.record-card:active {
  box-shadow: var(--shadow-lg);
  transform: scale(0.995);
}

.record-card-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  cursor: pointer;
}

.record-card-thumb {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-xs);
  object-fit: cover;
  background: #e8eaed;
  flex-shrink: 0;
}

.record-card-thumb.thumb-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: white;
  font-size: 1.5rem;
  font-weight: 700;
  text-transform: uppercase;
}

.record-card-info {
  flex: 1;
  min-width: 0;
}

.record-card-name {
  font-weight: 600;
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.record-card-date {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.record-card-meta {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.record-card-badge {
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-weight: 500;
}

.record-card-arrow {
  color: var(--text-secondary);
  font-size: 0.85rem;
  transition: transform 0.2s;
}

.record-card.expanded .record-card-arrow {
  transform: rotate(180deg);
}

.record-card-body {
  display: none;
  padding: 0 16px 16px;
  border-top: 1px solid var(--border);
}

.record-card.expanded .record-card-body {
  display: block;
}

.record-card-body .desc-text {
  font-size: 0.95rem;
  line-height: 1.6;
  margin-top: 14px;
  margin-bottom: 14px;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.record-card-body .card-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.record-card-body .card-actions .btn {
  flex: 1;
  font-size: 0.85rem;
  padding: 10px 14px;
  min-width: 100px;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.loading-box {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px 32px;
  text-align: center;
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.loading-box .spinner {
  width: 36px;
  height: 36px;
  border-width: 3px;
  border-color: rgba(26, 115, 232, 0.2);
  border-top-color: var(--primary);
}

.loading-text {
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--text);
}

.app-footer {
  text-align: center;
  padding: 20px 16px 32px;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.app-footer a {
  color: var(--text-secondary);
  text-decoration: none;
}

.app-footer a:hover {
  text-decoration: underline;
}

#toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #323232;
  color: white;
  padding: 20px 28px;
  border-radius: var(--radius);
  font-size: 1.15rem;
  font-weight: 500;
  z-index: 100;
  box-shadow: var(--shadow-lg);
  transition: opacity 0.3s, transform 0.3s;
  max-width: 90%;
  text-align: center;
  pointer-events: none;
}

#toast.toast-success {
  background: #e8f5e9;
  color: #1b5e20;
  border: 1px solid #a5d6a7;
}

#toast.toast-warning {
  background: #ffcc80;
  color: #bf360c;
  border: 1px solid #faab34;
}

.toast-hidden {
  opacity: 0;
  transform: translate(-50%, -50%) translateY(20px);
  pointer-events: none;
}

.toast-hidden.toast-success {
  transform: translate(-50%, -50%) translateY(20px);
}

.toast-hidden.toast-warning {
  transform: translate(-50%, -50%) translateY(20px);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.85);
  border: none;
  cursor: pointer;
}

.modal-content {
  position: relative;
  max-width: 100%;
  max-height: 90vh;
  z-index: 1;
}

.modal-content.modal-zoomable {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  max-height: 100vh;
  touch-action: none;
  overflow: hidden;
}

#modal-img-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  transform-origin: center center;
  will-change: transform;
}

#modal-img-wrapper img {
  max-width: 100%;
  max-height: 85vh;
  border-radius: var(--radius-xs);
  box-shadow: var(--shadow-xl);
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

#modal-img-wrapper.panning {
  cursor: grabbing;
}

#modal-img-wrapper:not(.panning) {
  cursor: grab;
}

.modal-close {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top, 0));
  right: 12px;
  width: 44px;
  height: 44px;
  background: rgba(255,255,255,0.95);
  color: var(--text);
  border: none;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  z-index: 1001;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.modal-close svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.modal-content.modal-form {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-xl);
  align-self: flex-start;
  margin-top: env(safe-area-inset-top, 0);
}

.modal-content.modal-form h3 {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.modal-content.modal-form .modal-subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 18px;
}

.modal-content.modal-form .field {
  margin-bottom: 16px;
}

#damage-edit-desc-wrapper,
#resolution-desc-wrapper {
  position: relative;
}

#damage-edit-desc-wrapper textarea,
#resolution-desc-wrapper textarea {
  padding-right: 56px;
  resize: vertical;
  min-height: 100px;
}

#btn-damage-edit-dictate {
  position: absolute;
  bottom: 8px;
  right: 8px;
}

#damage-edit-dictation-status {
  font-size: 0.85rem;
  font-weight: 500;
  margin-top: 6px;
  padding: 8px 12px;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--primary-dark);
  background: var(--primary-soft);
}

#damage-edit-dictation-status::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  animation: pulse 1.2s infinite;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.modal-actions .btn {
  flex: 1;
}

#btn-load-more {
  width: 100%;
  margin-top: 8px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.1); }
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    --bg: #121212;
    --surface: #1e1e1e;
    --text: #e8eaed;
    --text-secondary: #9aa0a6;
    --border: #3c4043;
    --primary: #8ab4f8;
    --primary-dark: #aecbfa;
    --primary-soft: rgba(138,180,248,0.15);
    --danger: #f28b82;
    --danger-dark: #f6aea9;
    --danger-soft: rgba(242,139,130,0.15);
    --success: #81c995;
    --success-soft: rgba(129,201,149,0.15);
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-xl: 0 10px 30px rgba(0,0,0,0.5);
  }

  html:not([data-theme="light"]) .image-placeholder {
    background: rgba(138,180,248,0.12);
  }

  html:not([data-theme="light"]) .image-placeholder:active {
    background: rgba(138,180,248,0.22);
  }

  html:not([data-theme="light"]) .validation-hint {
    background: #2d2d2d;
  }

  html:not([data-theme="light"]) .record-card-thumb {
    background: #2d2d2d;
  }
}

.menu-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 90;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.menu-backdrop.open {
  opacity: 1;
}

.side-menu {
  position: fixed;
  top: 0;
  right: 0;
  width: min(300px, 82vw);
  max-width: 100%;
  height: 100%;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-xl);
  z-index: 100;
  transform: translateX(105%);
  transition: transform 0.25s ease;
  display: flex;
  flex-direction: column;
}

.side-menu.open {
  transform: translateX(0);
}

.side-menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top));
  border-bottom: 1px solid var(--border);
  font-size: 1.1rem;
  font-weight: 600;
}

#menu-title {
  line-height: 1.25;
}

.side-menu-header .btn-icon {
  background: transparent;
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
}

.side-menu-list {
  list-style: none;
  padding: 12px 0;
  margin: 0;
}

.side-menu-list li {
  margin: 0;
}

.side-menu-separator {
  height: 1px;
  background: var(--border);
  margin: 10px 16px !important;
}

.side-menu-item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 18px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 1rem;
  font-weight: 500;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

.side-menu-item:active {
  background: var(--primary-soft);
}

.side-menu-item.side-menu-danger {
  color: var(--danger);
}

.side-menu-item.side-menu-danger:active {
  background: var(--danger-soft);
}

.side-menu-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  font-size: 1.15rem;
}

.side-menu-icon svg {
  width: 20px;
  height: 20px;
}

.side-menu-label {
  flex: 1;
  min-width: 0;
}

.theme-status {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--text-secondary);
  background: var(--bg);
  padding: 4px 8px;
  border-radius: var(--radius-xs);
}

.sync-badge {
  background: var(--warning);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  white-space: nowrap;
  line-height: 1.2;
  display: inline-flex;
  align-items: center;
  align-self: center;
}

.sync-badge.hidden {
  display: none;
}

.sync-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.records-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  line-height: 1.2;
}

.records-header h2 {
  margin: 0;
  line-height: inherit;
}

#records-section .records-header {
  margin-bottom: 16px;
}

#records-section .records-header h2 {
  margin-bottom: 0;
}

#records-section {
  position: relative;
}

#records-section.pull-to-refresh::before {
  content: '\2193 Zum Aktualisieren loslassen';
  display: block;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.85rem;
  padding: 12px 0;
  margin-top: -36px;
  transition: margin-top 0.2s ease;
}

#records-section.pull-to-refresh {
  padding-top: 36px;
}

/* Archive section */
#archive-section .records-header {
  margin-bottom: 16px;
}

.archive-status {
  padding: 8px 12px;
  margin-bottom: 12px;
  border-radius: var(--radius-xs);
  background: var(--primary-soft);
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.archive-status-loading {
  color: var(--primary);
}

#archive-tree {
  margin-bottom: 16px;
}

.archive-node {
  margin-bottom: 4px;
}

.archive-node-header {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text);
  font-size: 1rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease;
}

.archive-node-header:active {
  background: var(--primary-soft);
}

.archive-node-icon {
  display: inline-block;
  width: 16px;
  color: var(--primary);
  font-size: 0.85rem;
  transition: transform 0.15s ease;
}

.archive-year > .archive-node-header {
  font-weight: 600;
  font-size: 1.05rem;
}

.archive-month > .archive-node-header {
  padding-left: 28px;
  font-size: 0.95rem;
}

.archive-children {
  padding-left: 12px;
  margin-top: 4px;
}

.archive-children.hidden {
  display: none;
}

.archive-pdf-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px 10px 44px;
  margin-bottom: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--primary);
  text-decoration: none;
  font-size: 0.95rem;
  transition: background 0.15s ease;
}

.archive-pdf-item:active {
  background: var(--primary-soft);
}

.archive-pdf-date {
  font-weight: 500;
  min-width: 90px;
}

.archive-pdf-title {
  flex: 1;
  margin-left: 12px;
  color: var(--primary);
}

.archive-pdf-size {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-left: 12px;
  white-space: nowrap;
}

#archive-tree > .empty-state {
  padding: 24px 0;
}
