/* 색상은 lib/widgets/pixel_ui/pixel_ui.dart의 PixelPalette와 같은 값을 쓴다. */
:root {
  --base: #6b4e7a;
  --base-deep: #55406a;
  --night: #2e2140;
  --gold: #f7c948;
  --gold-dark: #b8862b;
  --gold-light: #ffe27a;
  --outline: #2a1b33;
  --card: #7e6290;
  --card-dim: #5e4870;
  --text: #fff6e5;
  --text-sub: #e8ddf0;
  --text-dim: #b7a6c6;
  --violet: #c79bff;
  --mint: #8cf0a8;
  --rose: #ff7a8a;
  --disabled: #6e6578;
}

@font-face {
  font-family: NeoDunggeunmo;
  src: url('fonts/neodgm.ttf') format('truetype');
  font-display: swap;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; }

body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  background: var(--base-deep);
  color: var(--text);
  font-family: NeoDunggeunmo, monospace;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: none;
}

.topbar {
  flex: none;
  padding: calc(env(safe-area-inset-top) + 8px) 16px 8px;
  background: var(--night);
  border-bottom: 3px solid var(--gold-dark);
}

.back {
  display: inline-block;
  padding: 4px 2px;
  color: var(--gold-light);
  text-decoration: none;
}

.frame {
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 10px 16px calc(env(safe-area-inset-bottom) + 12px);
}

.screen { height: 100%; }

.center {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 14px;
  text-align: center;
}

.title {
  margin: 0;
  color: var(--gold-light);
  font-size: 18px;
  font-weight: normal;
  text-shadow: 1px 1px 0 var(--outline);
}

.title.small { font-size: 16px; }
.dim { margin: 0; color: var(--text-dim); }
.center-text { padding: 24px 8px; text-align: center; }

.chat {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-header {
  display: flex;
  flex: none;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.chat-header .title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.right { margin-left: auto; font-size: 13px; white-space: nowrap; }

.badge {
  flex: none;
  padding: 0 6px;
  background: var(--night);
  border: 2px solid var(--gold-dark);
  color: var(--gold-light);
  font-size: 12px;
}

.modes {
  display: grid;
  flex: none;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
}

.mode {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  padding: 5px 2px;
  background: var(--card-dim);
  border: 2px solid var(--outline);
  color: var(--text-sub);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.mode b { font-weight: normal; }
.mode small { color: var(--text-dim); font-size: 11px; }
.mode.locked { opacity: 0.55; }
.mode.selected { color: var(--outline); box-shadow: inset 0 0 0 1px var(--text); }
.mode.selected small { color: var(--outline); }
.mode.mint.selected { background: var(--mint); }
.mode.gold.selected { background: var(--gold); }
.mode.violet.selected { background: var(--violet); }

.log {
  flex: 1;
  min-height: 0;
  padding: 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--night);
  border: 2px solid var(--outline);
  border-radius: 6px;
}

#older { width: 100%; margin-bottom: 8px; }

.bubble {
  width: fit-content;
  max-width: 85%;
  margin: 0 auto 6px 0;
  padding: 7px 10px;
  background: var(--card);
  border: 2px solid var(--outline);
  border-radius: 4px;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  font-size: 14px;
}

.bubble.user {
  margin: 0 0 6px auto;
  background: var(--base-deep);
  border-color: var(--gold-dark);
}

.composer {
  display: flex;
  flex: none;
  gap: 6px;
}

.input-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
}

#input {
  width: 100%;
  height: 100%;
  min-height: 42px;
  padding: 8px 52px 8px 10px;
  background: var(--night);
  border: 2px solid var(--gold-dark);
  border-radius: 4px;
  color: var(--text);
  font: inherit;
  font-size: 16px; /* iOS가 입력할 때 화면을 확대하지 않는 크기 */
  outline: none;
}

#input:focus { border-color: var(--gold); }
#input:disabled { border-color: var(--disabled); color: var(--text-dim); }

.counter {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  color: var(--text-dim);
  font-size: 11px;
  pointer-events: none;
}

.pixel-button {
  display: block;
  flex: none;
  padding: 9px 8px;
  border: 2px solid var(--outline);
  border-radius: 3px;
  box-shadow: 0 4px 0 var(--outline);
  margin-bottom: 4px;
  color: var(--outline);
  font: inherit;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.pixel-button:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--outline);
}

.pixel-button.gold { background: var(--gold); }
.pixel-button.card { background: var(--card); color: var(--text); }
.pixel-button.violet { background: var(--violet); }
.pixel-button.square { width: 44px; padding: 0; font-size: 18px; }

.pixel-button:disabled {
  background: var(--disabled);
  color: var(--text-dim);
  cursor: default;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: calc(env(safe-area-inset-bottom) + 90px);
  left: 16px;
  z-index: 10;
  max-width: 448px;
  margin: 0 auto;
  padding: 10px 12px;
  background: var(--night);
  border: 2px solid var(--gold);
  text-align: center;
}

.toast.error { border-color: var(--rose); }

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(20, 12, 28, 0.8);
}

.modal-box {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 360px;
  padding: 18px 16px;
  background: var(--base);
  border: 3px solid var(--gold);
  box-shadow: 0 0 0 3px var(--outline);
  text-align: center;
}

.modal-box p { margin: 0; }

.dim.small { font-size: 12px; }

.scanner {
  position: relative;
  height: 120px;
  overflow: hidden;
  background:
    repeating-linear-gradient(0deg, transparent 0 7px, rgba(127, 227, 240, 0.14) 7px 8px),
    var(--night);
  border: 3px solid var(--gold-dark);
}

.scanner::after {
  content: '';
  position: absolute;
  right: 0;
  left: 0;
  height: 6px;
  background: var(--violet);
  box-shadow: 0 0 12px var(--violet);
  animation: scan 1.6s steps(16) infinite alternate;
}

@keyframes scan {
  from { top: 0; }
  to { top: calc(100% - 6px); }
}

@media (prefers-reduced-motion: reduce) {
  .scanner::after { top: 50%; animation: none; }
}

.photo-frame {
  padding: 4px;
  background: var(--night);
  border: 3px solid var(--gold);
  box-shadow: 0 0 0 3px var(--outline);
}

.photo-frame img {
  display: block;
  width: 100%;
  max-height: 58dvh;
  object-fit: contain;
}
