:root {
  --bg: #f6f1e7;
  --bg-soft: #efe7d8;
  --card: #fffdf8;
  --text: #17120f;
  --subtle: #5f554c;
  --primary: #8f1e1e;
  --primary-hover: #701717;
  --success: #1d6f42;
  --error: #a4161a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  background: var(--bg);
  color: var(--text);
  line-height: 1.58;
}

.container {
  max-width: 980px;
  margin: 0 auto;
  padding: 18px 18px 40px;
}

.header {
  margin-bottom: 12px;
  padding: 4px 2px 8px;
  border-bottom: none;
}

.brand {
  margin: 0;
  font-weight: 800;
  font-size: 0.64rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--primary);
}

.header h1 {
  margin: 0 0 2px;
  font-size: clamp(1.65rem, 3.4vw, 2.35rem);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.header p {
  margin: 0 0 10px;
  color: var(--subtle);
  font-size: 0.74rem;
}

.feature-pills {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.feature-pills span {
  border: none;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.62rem;
  color: #3c322c;
  background: #fffaf1;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 18px;
  padding: 14px;
  border: none;
  border-radius: 14px;
  background: var(--card);
  box-shadow: none;
}

.panel label {
  font-weight: 700;
  font-size: 0.76rem;
  letter-spacing: 0.01em;
}

textarea {
  width: 100%;
  resize: vertical;
  border: none;
  border-radius: 12px;
  padding: 13px 14px;
  font: 500 0.72rem/1.45 ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;
  background: #fffcf6;
  color: #1b1612;
}

.textarea-wrap {
  position: relative;
}

textarea:focus-visible,
button:focus-visible {
  outline: 2px solid rgba(143, 30, 30, 0.65);
  outline-offset: 2px;
}

.actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(160px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

button {
  border: none;
  border-radius: 999px;
  padding: 9px 13px;
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  color: #ffffff;
  background: var(--primary);
  transition: transform 0.08s ease, background 0.15s ease;
  box-shadow: none;
}

button:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

.icon-btn {
  position: absolute;
  z-index: 2;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #352b24;
  background: #fff7ea;
  box-shadow: none;
  padding: 0;
}

#encodeBtn {
  background: #1074cc;
}

#encodeBtn:hover {
  background: #0d66b3;
}

#decodeBtn {
  background: rgba(0, 0, 0, 0.06);
  color: #1f1f1f;
}

#decodeBtn:hover {
  background: rgba(0, 0, 0, 0.12);
}

.icon-btn:hover {
  transform: none;
  background: #f6ead8;
}

.icon-btn.top-right {
  top: 8px;
  right: 8px;
}

.icon-btn.bottom-right {
  right: 8px;
  bottom: 18px;
}

#inputText {
  padding-right: 52px;
  padding-bottom: 52px;
}

#outputText {
  padding-right: 52px;
  padding-bottom: 52px;
}

.status {
  min-height: 1.4em;
  margin: 2px 2px 0;
  font-size: 0.72rem;
  font-weight: 700;
}

.status.success {
  color: var(--success);
}

.status.error {
  color: var(--error);
}

.preview-box {
  position: relative;
  border: none;
  border-radius: 12px;
  background: #fffaf1;
  padding: 10px;
}

.preview-box img {
  display: none;
  width: 100%;
  max-height: 240px;
  object-fit: contain;
  border-radius: 8px;
  background: rgba(127, 127, 127, 0.08);
}

.preview-placeholder {
  height: 240px;
  border-radius: 8px;
  background: var(--bg-soft);
  color: #8e8075;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-box.has-image .preview-placeholder {
  display: none;
}

.preview-box.has-image img {
  display: block;
}

#copyImageBtn {
  display: none;
}

.preview-box.has-image #copyImageBtn {
  display: inline-flex;
}

@media (max-width: 680px) {
  .container {
    padding: 10px 12px 28px;
  }

  .header {
    margin-bottom: 10px;
    padding: 2px 0 6px;
  }

  .header h1 {
    font-size: 1.8rem;
    margin-bottom: 0;
  }

  .header p {
    font-size: 0.74rem;
    margin-bottom: 8px;
  }

  .feature-pills {
    gap: 6px;
  }

  .feature-pills span {
    font-size: 0.62rem;
    padding: 1px 8px;
  }

  .actions {
    grid-template-columns: 1fr;
  }
}
