:root {
  --gold: #c9a24a;
  --gold-soft: #e4c98a;
  --bg: #0b0b0c;
  --bg-panel: #17171a;
  --line: #2c2c2f;
  --text: #f2f0ec;
  --text-dim: #9a968d;
  --danger: #c0554a;
}

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

[hidden] { display: none !important; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Sans', sans-serif;
  line-height: 1.6;
}

/* ── ログイン画面 ── */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-box {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-title {
  text-align: center;
  font-size: 1.3rem;
  letter-spacing: .1em;
  color: var(--gold-soft);
  margin-bottom: 10px;
}
.login-hint {
  text-align: center;
  font-size: .8rem;
  color: var(--text-dim, #999);
  margin: -6px 0 4px;
  line-height: 1.5;
}
.login-input {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 1rem;
}
.login-btn {
  background: var(--gold);
  color: #0b0b0c;
  border: none;
  padding: 12px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
}
.login-error {
  color: var(--danger);
  font-size: .85rem;
  text-align: center;
  min-height: 1.2em;
}

/* ── 管理画面 ── */
.admin-screen {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px 100px;
}
.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
}
.admin-logo {
  font-size: 1.2rem;
  letter-spacing: .1em;
  color: var(--gold-soft);
}
.admin-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.admin-view-link {
  color: var(--text-dim);
  text-decoration: none;
  font-size: .85rem;
}
.admin-logout-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-dim);
  padding: 8px 14px;
  border-radius: 20px;
  font-size: .8rem;
  cursor: pointer;
}
.admin-status {
  min-height: 1.4em;
  font-size: .85rem;
  color: var(--gold-soft);
  margin-bottom: 14px;
}

.admin-section-title {
  font-size: 1rem;
  letter-spacing: .05em;
  color: var(--gold-soft);
  margin-bottom: 12px;
}

.admin-settings-card {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.admin-settings-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.admin-settings-col {
  flex: 1;
  min-width: 160px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.admin-settings-col .admin-field-label {
  width: auto;
}
.admin-settings-preview {
  width: 100%;
  height: 120px;
  object-fit: contain;
  object-position: bottom;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101012;
  /* ラベルの行数が列によって違っても（例:「背景画像」は2〜3行、「ロゴ画像」は1行）、
     画像から下（画像+ボタン）のブロックが常にカラムの下端に揃うように、
     ラベルとの間の余白をここで吸収する。 */
  margin-top: auto;
}
.admin-settings-btns {
  display: flex;
  gap: 8px;
}
.admin-settings-btns .admin-photo-btn {
  flex: 1;
  padding: 8px 4px;
}
.admin-settings-hint {
  font-size: .72rem;
  color: var(--text-dim);
  line-height: 1.6;
  margin-top: -6px;
}
.admin-settings-save-btn {
  align-self: flex-start;
  background: var(--gold);
  color: #0b0b0c;
  border: none;
  padding: 10px 24px;
  border-radius: 20px;
  font-size: .85rem;
  font-weight: bold;
  cursor: pointer;
}

.admin-host-list-header {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.admin-host-list-header .admin-section-title {
  margin-bottom: 0;
}
.admin-host-count {
  font-size: .8rem;
  color: var(--text-dim);
}
.admin-add-btn {
  margin-left: auto;
  background: transparent;
  border: 1px solid var(--gold);
  color: var(--gold-soft);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: .8rem;
  cursor: pointer;
}

.admin-host-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.admin-host-card {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: opacity .15s ease;
}
.admin-host-card.is-dragging {
  opacity: .35;
}
.admin-host-card.is-collapsed {
  gap: 0;
}
.admin-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.admin-drag-handle {
  cursor: grab;
  color: var(--text-dim);
  font-size: 1rem;
  letter-spacing: -2px;
  user-select: none;
  touch-action: none;
  flex-shrink: 0;
}
.admin-collapse-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--gold-soft);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: .65rem;
  cursor: pointer;
  flex-shrink: 0;
}
.admin-card-header-thumb {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  background: #222;
}
.admin-card-id {
  flex: 1;
  min-width: 0;
  font-size: .8rem;
  color: var(--text);
  letter-spacing: .02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.admin-card-id small {
  font-size: .65rem;
  color: var(--text-dim);
}
.admin-card-header-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}
.admin-host-card.is-collapsed .admin-card-header-actions {
  display: none;
}
.admin-save-one-btn {
  background: transparent;
  border: 1px solid var(--gold);
  color: var(--gold-soft);
  padding: 5px 12px;
  border-radius: 14px;
  font-size: .7rem;
  cursor: pointer;
}
.admin-remove-btn {
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 5px 12px;
  border-radius: 14px;
  font-size: .7rem;
  cursor: pointer;
  flex-shrink: 0;
}
.admin-card-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow: hidden;
}
.admin-host-card.is-collapsed .admin-card-body {
  display: none;
}
.admin-card-main {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 16px;
}
.admin-photo-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.admin-photo-thumb {
  width: 96px;
  height: 96px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #222;
}
.admin-photo-btn {
  font-size: .68rem;
  padding: 5px 0;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text-dim);
  border-radius: 6px;
  cursor: pointer;
  text-align: center;
}
.admin-photo-btn input[type="file"] {
  display: none;
}
.admin-photo-btn:disabled {
  opacity: .35;
  cursor: default;
}
.admin-photo-reorder-btns {
  margin-top: 6px;
}

.admin-fields {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.admin-fields-row {
  display: flex;
  gap: 8px;
  align-items: center;
  min-width: 0;
}
.admin-field-label {
  font-size: .7rem;
  color: var(--text-dim);
  width: 68px;
  flex-shrink: 0;
}
.admin-field-label small {
  font-size: 1em;
  font-weight: normal;
  opacity: .75;
}
.admin-input,
.admin-textarea {
  flex: 1;
  min-width: 0;
  background: #101012;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 6px;
  font-size: .9rem;
  font-family: inherit;
}
.admin-textarea {
  resize: vertical;
  min-height: 40px;
}
.admin-color-input {
  flex-shrink: 0;
  width: 48px;
  height: 38px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #101012;
  cursor: pointer;
}
.admin-text-color-preview {
  flex-shrink: 0;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #101012;
  font-size: .85rem;
  white-space: nowrap;
}
.admin-status-toggle {
  padding: 7px 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text-dim);
  font-size: .8rem;
  cursor: pointer;
  flex-shrink: 0;
}
.admin-status-toggle.is-working {
  background: var(--gold);
  border-color: var(--gold);
  color: #0b0b0c;
  font-weight: bold;
}
.admin-visibility-toggle {
  padding: 7px 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text-dim);
  font-size: .8rem;
  cursor: pointer;
  flex-shrink: 0;
}
.admin-visibility-toggle.is-hidden {
  background: #c0554a;
  border-color: #c0554a;
  color: #fff;
  font-weight: bold;
}
.admin-hidden-badge {
  color: #c0554a;
  font-weight: bold;
}
.admin-host-card.is-hidden-host {
  opacity: .55;
}
.admin-sns-row {
  display: flex;
  gap: 8px;
  min-width: 0;
}
.admin-sns-row .admin-input {
  font-size: .8rem;
}

.admin-photos-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}
.admin-photos-section .admin-field-label {
  width: auto;
}
.admin-photo-slots {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.admin-photo-slot {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.admin-photo-slot-img {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
}
.admin-photo-slot-empty {
  width: 100%;
  aspect-ratio: 2 / 3;
  border-radius: 8px;
  border: 1px dashed var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: .75rem;
  background: #101012;
}

.admin-save-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(11, 11, 12, .95);
  border-top: 1px solid var(--line);
  padding: 14px 16px;
  display: flex;
  justify-content: center;
  z-index: 50;
}
.admin-save-btn {
  background: var(--gold);
  color: #0b0b0c;
  border: none;
  padding: 14px 40px;
  border-radius: 30px;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  max-width: 400px;
  width: 100%;
}
.admin-save-btn:disabled {
  opacity: .5;
  cursor: default;
}

@media (max-width: 480px) {
  .admin-card-main {
    grid-template-columns: 1fr;
  }
  .admin-photo-col {
    flex-direction: row;
    align-items: center;
  }
}

/* ── 画像クロップモーダル ── */
.crop-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}
.crop-modal-inner {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  max-width: 360px;
  width: 100%;
}
.crop-title {
  font-size: .95rem;
  color: var(--gold-soft);
  letter-spacing: .05em;
}
.crop-stage {
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  line-height: 0;
}
#crop-canvas {
  touch-action: none;
  cursor: grab;
  width: 100%;
  max-width: 320px;
  height: auto;
  display: block;
}
#crop-canvas:active {
  cursor: grabbing;
}
.crop-zoom-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
}
.crop-zoom-label {
  font-size: .75rem;
  color: var(--text-dim);
  flex-shrink: 0;
}
.crop-zoom-row input[type="range"] {
  flex: 1;
  min-width: 0;
}
.crop-hint {
  font-size: .7rem;
  color: var(--text-dim);
  text-align: center;
}
.crop-actions {
  width: 100%;
  display: flex;
  gap: 10px;
}
.crop-cancel-btn,
.crop-apply-btn {
  flex: 1;
  padding: 10px;
}
