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

* { box-sizing: border-box; }

:root {
  --paper-w: 10cm;
  --paper-h: 15cm;
  --paper-pad: 1cm;
  --accent: #d98a8a;
  --border: #e5e5e5;
  --text: #222;
  --muted: #777;
  --bg: #faf7f3;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans KR", sans-serif;
}

.app {
  display: grid;
  grid-template-columns: 320px 1fr;
  min-height: 100vh;
}

.panel {
  padding: 24px;
  background: #fff;
  border-right: 1px solid var(--border);
  overflow-y: auto;
}

.panel h1 {
  font-size: 20px;
  margin: 0 0 20px;
}

.field { margin-bottom: 16px; }

.field label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

.field input {
  width: 100%;
  padding: 8px 10px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
}

.field input:focus {
  outline: none;
  border-color: var(--accent);
}

.hint-sm {
  font-size: 11px;
  color: var(--muted);
  margin: 6px 0 0;
  line-height: 1.4;
}

.stepper { display: flex; gap: 8px; }

.stepper button {
  flex: 1;
  padding: 8px 0;
  font-size: 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}

.stepper button:hover { background: #f6f2ee; }
.stepper button:active { background: #ece7e1; }

.actions {
  display: flex;
  gap: 8px;
  margin-top: 24px;
}

.actions button {
  flex: 1;
  padding: 10px 0;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}

.actions .primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.actions .primary:hover { opacity: 0.9; }

.status {
  margin-top: 12px;
  font-size: 13px;
  min-height: 18px;
}

.status.error { color: #c44; }
.status.success { color: #2a8; }

.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  gap: 12px;
}

.letter {
  position: relative;
  width: var(--paper-w);
  height: var(--paper-h);
  background-image: url("images/bg-test.jpg");
  background-size: cover;
  background-position: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.letter-body {
  position: absolute;
  top: var(--paper-pad);
  left: var(--paper-pad);
  width: calc(var(--paper-w) - 2 * var(--paper-pad));
  height: calc(var(--paper-h) - 2 * var(--paper-pad));
  padding: 0;
  margin: 0;
  border: none;
  outline: none;
  background: transparent;
  color: #000;
  font-family: "MapoFlowerIsland", serif;
  font-size: 16px;
  line-height: 1.6;
  overflow: hidden;
  white-space: pre-wrap;
  word-break: break-word;
  text-align: center;
  cursor: text;
}

.letter-body:empty::before {
  content: attr(data-placeholder);
  color: rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

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

.category-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.cat-btn {
  padding: 8px 6px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}

.cat-btn:hover { background: #f6f2ee; border-color: var(--accent); }
.cat-btn:active { background: #ece7e1; }

.modal[hidden] { display: none; }

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

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
}

.modal-content {
  position: relative;
  background: #fff;
  border-radius: 10px;
  width: min(560px, 92vw);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

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

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 0 4px;
}

.modal-close:hover { color: var(--text); }

.phrase-list {
  overflow-y: auto;
  padding: 12px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.phrase-card {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}

.phrase-card:hover {
  border-color: var(--accent);
  background: #fdf7f5;
}
