/* Reset-ish */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans KR', sans-serif; }
button, input, select, textarea { font: inherit; }

:root {
  --bg: #f5f5f5;
  --left: #ffffff;
  --right: #ffec94;
  --text: #141414;
  --small: #787878;
  --chip: #e6e6e6;
  --radius: 18px;
  --gap-msg: 8px;
  --gap-group: 18px;
  --padding: 14px;
  --avatar: 44px;
  --max-bubble: 72%;
}

body { background: #0f1115; color: #eaeaea; }
.app-header, .app-footer { padding: 16px 20px; background: #0a0c10; border-bottom: 1px solid #171a21; }
.app-footer { border-top: 1px solid #171a21; border-bottom: none; }
.app-header h1 { margin: 0; font-size: 20px; }
.app-header p { margin: 6px 0 0; color: #9aa4b2; }
.app-main { display: grid; grid-template-columns: 420px 1fr; gap: 12px; padding: 12px; min-height: calc(100vh - 110px); }
.controls { background: #0a0c10; border: 1px solid #171a21; border-radius: 12px; padding: 12px; }
.controls .row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.controls label { color: #9aa4b2; }
.controls textarea { width: 100%; padding: 10px; border-radius: 8px; border: 1px solid #171a21; background: #0f1115; color: #eaeaea; }
.controls button { background: #1f6feb; color: white; border: none; padding: 8px 12px; border-radius: 8px; cursor: pointer; }
.controls button:hover { filter: brightness(1.1); }
.controls input, .controls select { background: #0f1115; color: #eaeaea; border: 1px solid #171a21; border-radius: 8px; padding: 6px 8px; }
.hint { color: #9aa4b2; }

.preview-wrap { display: flex; align-items: flex-start; justify-content: center; padding: 8px; }
.preview {
  background: var(--bg);
  border-radius: 16px;
  box-shadow: 0 0 0 1px rgba(0,0,0,.12), 0 8px 24px rgba(0,0,0,.25);
  overflow: hidden;
}
.chat {
  padding: 10px 12px 12px;
}
.time-chip {
  display: inline-block;
  margin: 10px auto;
  font-size: 12px;
  color: var(--small);
  background: var(--chip);
  padding: 6px 10px;
  border-radius: 999px;
}

.msg-group { display: grid; grid-template-columns: auto 1fr; gap: 8px 8px; margin: var(--gap-group) 8px; }
.msg-group.me { grid-template-columns: 1fr auto; }
.avatar {
  width: var(--avatar);
  height: var(--avatar);
  border-radius: 50%;
  background: #d1e3ff;
  border: 3px solid #fff;
  display: grid;
  place-items: center;
  color: #2d4a7a;
  font-weight: 700;
}
.avatar .icon-person {
  width: 60%;
  height: 60%;
  position: relative;
}
.bubble {
  max-width: var(--max-bubble);
  display: inline-flex;
  padding: var(--padding);
  border-radius: var(--radius);
  color: var(--text);
  box-shadow: 0 1px 0 rgba(0,0,0,.04);
  position: relative;
}
.bubble.left { background: var(--left); }
.bubble.right { background: var(--right); margin-left: auto; }
.bubble.notice { background: #eaeaea; color: #333; }
.bubble img.content-image {
  max-width: 100%;
  display: block;
  border-radius: 12px;
  margin-bottom: 8px;
}
.meta {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: flex-end;
  margin-top: 6px;
  font-size: 12px;
  color: var(--small);
}
.meta.left { justify-content: flex-start; }

.tail {
  position: absolute;
  bottom: -2px;
  width: 0; height: 0;
  border: 10px solid transparent;
}
.tail.left {
  left: -6px;
  border-right-color: var(--left);
  border-left: none;
}
.tail.right {
  right: -6px;
  border-left-color: var(--right);
  border-right: none;
}

.theme-kakaotalk { --bg:#f5f5f5; --left:#ffffff; --right:#ffec94; --text:#141414; --small:#787878; --chip:#e6e6e6; }
.theme-light    { --bg:#f7f7f9; --left:#ffffff; --right:#e7f0ff; --text:#1a1a1a; --small:#767676; --chip:#ececec; }
.theme-dark     { --bg:#1c1f24; --left:#2a2f36; --right:#3a4150; --text:#f0f4f8; --small:#a0a8b0; --chip:#343a43; }
