:root {
  --primary-color: #f9c74f;
  --primary-color-hover: #f3b72b;
  --border-color: #ced4da;
  --primary-text: #343a40;
  --secondary-text: #f8f9fa;
  --accent-text: #adb5bd;
  --background-primary: #f8f9fa;
  --background-secondary: #e9ecef;
  --background-messages: #f8e4cd;
  --background-transparent: rgba(0, 0, 0, 0.05);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "IBM Plex Sans", sans-serif;
  background: var(--background-primary);
  color: var(--primary-text);
  min-height: 100vh;
}

.app {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem;
}

.header {
  margin-bottom: 1.25rem;
}

.header h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--primary-text);
}

.main {
  display: grid;
  grid-template-columns: minmax(0, 520px) 300px;
  gap: 1.25rem;
  align-items: start;
  justify-content: center;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.sidebar-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sidebar-note {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.4;
  color: var(--accent-text);
  text-align: center;
}

.sidebar-note[hidden] {
  display: none;
}

.btn {
  padding: 0.65rem 1.1rem;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  border: none;
  border-radius: 6px;
  background: var(--primary-color);
  color: var(--primary-text);
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.btn:hover:not(:disabled) {
  background: var(--primary-color-hover);
}

.btn:disabled {
  background: var(--background-secondary);
  color: var(--accent-text);
  cursor: not-allowed;
}

.btn-delete {
  background: var(--secondary-text);
  border: 1px solid var(--border-color);
  color: var(--primary-text);
}

.btn-delete:hover:not(:disabled) {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #991b1b;
}

.btn-download {
  background: var(--secondary-text);
  border: 1px solid var(--border-color);
  color: var(--primary-text);
}

.btn-download:hover:not(:disabled) {
  background: #dcfce7;
  border-color: #86efac;
  color: #166534;
}

.text-tools {
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.text-tools[hidden] {
  display: none;
}

.tool-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.tool-row:last-child {
  margin-bottom: 0;
}

.tool-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--primary-text);
}

.tool-buttons {
  display: flex;
  gap: 0.4rem;
}

.btn-tool {
  padding: 0.4rem 0.7rem;
  font-size: 0.85rem;
  min-width: 3rem;
  background: var(--background-primary);
  border: 1px solid var(--border-color);
  color: var(--primary-text);
}

.btn-tool:hover:not(:disabled) {
  background: var(--primary-color);
  border-color: var(--primary-color);
}

.btn-tool.is-active {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: var(--primary-text);
}

.canvas-panel {
  position: relative;
  width: 100%;
  max-width: 520px;
  justify-self: center;
  background: var(--secondary-text);
  border: 1px solid #ccc;
  padding: 19px;
  border-radius: 3px;
  overflow: hidden;
}

.canvas-panel.has-image {
  width: 100%;
}

.canvas-wrapper[hidden] {
  display: none !important;
}

.canvas-wrapper:not([hidden]) {
  display: block;
  padding: 0;
  background: var(--background-secondary);
  line-height: 0;
}

.canvas-wrapper .canvas-container {
  line-height: 0;
}

.canvas-wrapper canvas {
  display: block;
}

.message[hidden] {
  display: none !important;
}

.message:not([hidden]) {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 240px;
  padding: 2rem 1.5rem;
  text-align: center;
  background: var(--background-messages);
}

.message-content {
  max-width: 26rem;
}

.message-title {
  margin: 0 0 0.75rem;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--primary-text);
}

.message-body {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--accent-text);
}

.message-body code {
  display: inline-block;
  margin-top: 0.35rem;
  padding: 0.35rem 0.5rem;
  font-size: 0.85rem;
  color: var(--primary-text);
  background: var(--background-transparent);
  border-radius: 4px;
  word-break: break-all;
}

.editor-panel {
  background: var(--secondary-text);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1.25rem;
  height: fit-content;
}

.editor-panel h2 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--primary-text);
}

.hint {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  color: var(--accent-text);
}

.text-editor {
  width: 100%;
  height: 220px;
  min-height: 220px;
  max-height: 220px;
  padding: 0.75rem;
  font-size: 0.95rem;
  line-height: 1.5;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  resize: none;
  font-family: Impact, sans-serif;
  color: var(--primary-text);
  background: var(--background-primary);
  text-transform: uppercase;
}

.text-editor:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(249, 199, 79, 0.25);
}

.text-editor:disabled {
  background: var(--background-secondary);
  color: var(--accent-text);
}

@media (max-width: 768px) {
  .app {
    padding: 1rem;
  }

  .main {
    display: flex;
    flex-direction: column;
    gap: 1rem;
  }

  .canvas-panel {
    order: 1;
    width: 100%;
    max-width: none;
    justify-self: stretch;
  }

  .sidebar {
    order: 2;
    width: 100%;
  }

  .sidebar-actions {
    width: 100%;
  }

  #add-text-btn,
  #delete-text-btn,
  #download-btn {
    width: 100%;
  }
}
