:root {
  --color-bg: #f5f6f8;
  --color-surface: #ffffff;
  --color-border: #e2e5ea;
  --color-text: #1c2027;
  --color-text-muted: #6b7280;
  --color-primary: #d0021b; /* 東急赤に寄せたアクセント */
  --color-primary-dark: #a80016;
  --color-accent: #0b5fff;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: "Hiragino Sans", "Yu Gothic", "Noto Sans JP", -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
}

header.app-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

header.app-header .brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

header.app-header .brand .badge {
  background: var(--color-primary);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: 0.02em;
}

header.app-header h1 {
  font-size: 16px;
  margin: 0;
  font-weight: 700;
}

header.app-header .logout-link {
  font-size: 13px;
  color: var(--color-text-muted);
  text-decoration: none;
}

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: 96px;
}

.selector-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}

.selector-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.field {
  flex: 1 1 200px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted);
}

select, input[type="text"], input[type="password"] {
  appearance: none;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 15px;
  background: #fff;
  color: var(--color-text);
}

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

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 16px;
}

.tab-btn {
  border: none;
  background: none;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.tab-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}

.card h2 {
  font-size: 14px;
  margin: 0 0 12px;
  color: var(--color-text-muted);
  font-weight: 700;
}

.floorplan-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.floorplan-header h2 {
  margin: 0;
}

.progress-badge {
  font-size: 12px;
  font-weight: 700;
  color: var(--color-primary-dark);
  background: #fdecee;
  padding: 4px 10px;
  border-radius: 999px;
}

.progress-badge span {
  font-size: 13px;
}

.floorplan-toolbar {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  margin-bottom: 4px;
}

.floorplan-toolbar input[type="text"] {
  flex: 1;
}

#editModeBtn.active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

.floorplan-hint {
  font-size: 12px;
  color: var(--color-text-muted);
  margin: 4px 0 10px;
}

.floorplan-hint.edit-hint {
  color: var(--color-primary-dark);
  font-weight: 600;
}

.floorplan-wrap {
  position: relative;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  overflow: hidden;
  background: #fafafa;
  touch-action: none;
}

.floorplan-wrap img {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
  -webkit-user-drag: none;
}

.marker-layer {
  position: absolute;
  inset: 0;
}

.panel-marker {
  position: absolute;
  transform: translate(-50%, -50%);
  min-width: 15px;
  height: 15px;
  padding: 0 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  border: 1.5px solid #9aa1ab;
  color: #4b5563;
  font-size: 7px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  white-space: nowrap;
  line-height: 1;
}

.panel-marker.has-photo {
  background: #1fa459;
  border-color: #17803f;
  color: #fff;
}

.panel-marker.editing {
  border-color: var(--color-primary);
  border-style: dashed;
}

.panel-marker.highlight {
  animation: marker-pulse 1s ease-in-out 2;
  z-index: 5;
}

@keyframes marker-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(208, 2, 27, 0.6); }
  50% { box-shadow: 0 0 0 6px rgba(208, 2, 27, 0); }
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 20, 26, 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
}

.modal-card {
  background: #fff;
  border-radius: 14px 14px 0 0;
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
}

@media (min-width: 560px) {
  .modal-overlay {
    align-items: center;
  }
  .modal-card {
    border-radius: 14px;
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.modal-header h3 {
  margin: 0;
  font-size: 16px;
}

.modal-close {
  border: none;
  background: #f1f2f4;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 16px;
  color: var(--color-text-muted);
  cursor: pointer;
}

.empty-state {
  color: var(--color-text-muted);
  font-size: 14px;
  padding: 24px 8px;
  text-align: center;
}

.upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 12px 18px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  justify-content: center;
}

.upload-btn:active {
  background: var(--color-primary-dark);
}

.secondary-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.photo-thumb {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--color-border);
  aspect-ratio: 1 / 1;
  background: #eee;
}

.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.photo-thumb .del-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}

.footer-actions {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  display: flex;
  gap: 10px;
  z-index: 20;
}

.footer-actions button {
  flex: 1;
}

.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: #1c2027;
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 30;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
}

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  background: #fff;
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 32px 28px;
  width: 100%;
  max-width: 360px;
}

.login-card h1 {
  font-size: 18px;
  margin-bottom: 4px;
}

.login-card p {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-top: 0;
  margin-bottom: 20px;
}

.login-card .error-msg {
  color: var(--color-primary);
  font-size: 13px;
  margin-top: 10px;
  min-height: 18px;
}

@media (max-width: 480px) {
  main {
    padding: 12px;
  }
}
