/* Globale Variable für Kachelgröße (wird per JS geändert) */
:root {
  --cell-size: 40px;
}

/* Grundlayout */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background-color: #f3f4f6;
  color: #111827;
}

/* Header */
.app-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #111827;
  color: #f9fafb;
}

.branding {
  display: flex;
  align-items: center;
  gap: 10px;
}

.branding h1 {
  font-size: 1.4rem;
  margin: 0;
}

.branding p {
  font-size: 0.85rem;
  margin: 2px 0 0;
  opacity: 0.85;
}

.main-nav {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.main-nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.main-nav a {
  font-size: 0.85rem;
  color: #e5e7eb;
  text-decoration: none;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
}

.main-nav a:hover {
  border-color: #e5e7eb;
  background: rgba(15, 23, 42, 0.4);
}

.subline {
  font-size: 0.8rem;
  opacity: 0.85;
}


.logo-square {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #f97316, #ec4899);
  border-radius: 6px;
}

.subline {
  font-size: 0.8rem;
  opacity: 0.9;
}

/* Hauptbereich */
.app-main {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1.4fr) minmax(0, 1.2fr);
  gap: 16px;
  padding: 16px;
}

.panel {
  background: #ffffff;
  border-radius: 10px;
  padding: 12px 14px 14px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
}

.panel h2 {
  margin: 0 0 10px;
  font-size: 1.05rem;
}

/* Controls */
.control-group {
  margin-bottom: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.shapes-group {
  align-items: flex-start;
}

.control-group .label {
  font-weight: 600;
  font-size: 0.85rem;
  margin-right: 4px;
}

.shapes-group .label {
  flex-basis: 100%;
}

.control-group label {
  font-size: 0.8rem;
}

/* Werkzeug-Toolbar */
.tool-toolbar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  width: 100%;
}

.tool-item {
  display: grid;
  grid-template-columns: 32px 1fr;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  min-height: 44px;
}

.tool-item:hover {
  border-color: #2563eb;
  background: #eff6ff;
}

.tool-item input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.tool-icon {
  --tool-size: 24px;
  width: var(--tool-size);
  height: var(--tool-size);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: #111827;
  color: #111827;
  position: relative;
}

.tool-text {
  font-size: 0.78rem;
  color: #111827;
}

.tool-item input:checked + .tool-icon {
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.35);
  background: #2563eb;
}

.tool-item input:checked ~ .tool-text {
  color: #1d4ed8;
  font-weight: 600;
}

/* Form-Icons */
.tool-icon-square {
  background: #111827;
}

.tool-icon-circle {
  background: #111827;
  border-radius: 50%;
}

.tool-icon-triangle {
  background: transparent;
  border-radius: 0;
}

.tool-icon-triangle::before {
  content: "";
  position: absolute;
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 16px solid #111827;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -45%);
}

.tool-icon-diamond {
  background: #111827;
  transform: rotate(45deg) scale(0.85);
}

.tool-icon-dot {
  background: transparent;
}

.tool-icon-dot::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #111827;
}

.tool-icon-rect-h {
  background: transparent;
}

.tool-icon-rect-h::before {
  content: "";
  width: 22px;
  height: 10px;
  background: #111827;
  border-radius: 2px;
}

.tool-icon-rect-v {
  background: transparent;
}

.tool-icon-rect-v::before {
  content: "";
  width: 10px;
  height: 22px;
  background: #111827;
  border-radius: 2px;
}

.tool-icon-ellipse-h {
  background: transparent;
}

.tool-icon-ellipse-h::before {
  content: "";
  width: 22px;
  height: 12px;
  background: #111827;
  border-radius: 50%;
}

.tool-icon-ellipse-v {
  background: transparent;
}

.tool-icon-ellipse-v::before {
  content: "";
  width: 12px;
  height: 22px;
  background: #111827;
  border-radius: 50%;
}

.tool-icon-semi-up {
  background: transparent;
  border-radius: 0;
}

.tool-icon-semi-up::before {
  content: "";
  width: 22px;
  height: 11px;
  background: #111827;
  border-radius: 12px 12px 0 0;
}

.tool-icon-semi-down {
  background: transparent;
}

.tool-icon-semi-down::before {
  content: "";
  width: 22px;
  height: 11px;
  background: #111827;
  border-radius: 0 0 12px 12px;
}

.tool-icon-semi-left {
  background: transparent;
}

.tool-icon-semi-left::before {
  content: "";
  width: 11px;
  height: 22px;
  background: #111827;
  border-radius: 12px 0 0 12px;
}

.tool-icon-semi-right {
  background: transparent;
}

.tool-icon-semi-right::before {
  content: "";
  width: 11px;
  height: 22px;
  background: #111827;
  border-radius: 0 12px 12px 0;
}

.tool-icon-quarter-tl,
.tool-icon-quarter-tr,
.tool-icon-quarter-bl,
.tool-icon-quarter-br {
  background: transparent;
}

.tool-icon-quarter-tl::before,
.tool-icon-quarter-tr::before,
.tool-icon-quarter-bl::before,
.tool-icon-quarter-br::before {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  background: #111827;
}

.tool-icon-quarter-tl::before {
  border-radius: 100% 0 0 0;
  top: 0;
  left: 0;
}

.tool-icon-quarter-tr::before {
  border-radius: 0 100% 0 0;
  top: 0;
  right: 0;
}

.tool-icon-quarter-bl::before {
  border-radius: 0 0 0 100%;
  bottom: 0;
  left: 0;
}

.tool-icon-quarter-br::before {
  border-radius: 0 0 100% 0;
  bottom: 0;
  right: 0;
}

.tool-icon-line-main,
.tool-icon-line-anti {
  background: transparent;
}

.tool-icon-line-main::before,
.tool-icon-line-anti::before {
  content: "";
  width: 26px;
  height: 4px;
  background: #111827;
  border-radius: 999px;
  position: absolute;
}

.tool-icon-line-main::before {
  transform: rotate(45deg);
}

.tool-icon-line-anti::before {
  transform: rotate(-45deg);
}

.tool-icon-erase {
  background: transparent;
  border: 1px dashed #111827;
}

.tool-icon-erase::before,
.tool-icon-erase::after {
  content: "";
  width: 20px;
  height: 2px;
  background: #111827;
  position: absolute;
}

.tool-icon-erase::before {
  transform: rotate(45deg);
}

.tool-icon-erase::after {
  transform: rotate(-45deg);
}

#triangle-orientation {
  padding: 4px 6px;
  font-size: 0.85rem;
}

#triangle-orientation-group {
  transition: opacity 0.15s ease;
  opacity: 0.5; /* deaktiviert, bis Dreieck gewählt */
}

/* Aufgabensteuerung */
#task-controls {
  opacity: 0.4;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

#task-controls.active {
  opacity: 1;
  pointer-events: auto;
}

/* Input */
#color-picker {
  width: 60px;
  height: 30px;
  padding: 0;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #ffffff;
}

.control-group.buttons {
  margin-top: 4px;
}

/* Schnellfarben */
.quick-colors .color-swatch {
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid #d1d5db;
  font-size: 0.8rem;
  background: #ffffff;
  color: #111827;
  cursor: pointer;
}

.quick-colors .color-swatch:hover {
  border-color: #111827;
}

.quick-colors .color-swatch[data-color="#000000"] {
  background: #000000;
  color: #ffffff;
}

.quick-colors .color-swatch[data-color="#ffffff"] {
  background: #ffffff;
  color: #111827;
}

.quick-colors .color-swatch[data-color="#f97316"] {
  background: #f97316;
  color: #111827;
}

.quick-colors .color-swatch[data-color="#ef4444"] {
  background: #ef4444;
  color: #ffffff;
}

.quick-colors .color-swatch[data-color="#22c55e"] {
  background: #22c55e;
  color: #111827;
}

.quick-colors .color-swatch[data-color="#0ea5e9"] {
  background: #0ea5e9;
  color: #111827;
}

.quick-colors .color-swatch[data-color="#1d4ed8"] {
  background: #1d4ed8;
  color: #ffffff;
}

.quick-colors .color-swatch[data-color="#a855f7"] {
  background: #a855f7;
  color: #ffffff;
}

.quick-colors .color-swatch[data-color="#eab308"] {
  background: #eab308;
  color: #111827;
}

button {
  border: none;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 0.85rem;
  cursor: pointer;
  background: #2563eb;
  color: #ffffff;
}

button:hover {
  background: #1d4ed8;
}

button:active {
  transform: translateY(1px);
}

.hint {
  font-size: 0.78rem;
  color: #6b7280;
  margin-top: 6px;
}

/* Zoom-Label */
.zoom-label {
  font-size: 0.78rem;
  color: #6b7280;
}

/* Grid */
.panel-grid {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.grid {
  display: grid;
  grid-template-columns: repeat(8, var(--cell-size));
  grid-template-rows: repeat(8, var(--cell-size));
  gap: 0;
  padding: 0;
  background: #111827;
  border-radius: 10px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.15);
}

.cell {
  width: var(--cell-size);
  height: var(--cell-size);
  background: #ffffff;
  border-radius: 0;
  border: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  padding: 0;
}

/* Fehler-Markierung im Aufgabenmodus */
.cell-error {
  box-shadow: inset 0 0 0 2px #ef4444;
}

/* Raster ausblenden */
.grid-no-lines .cell {
  border-color: transparent;
}

/* Aufgabe-Vorschau */
.task-preview-container {
  margin-top: 10px;
  text-align: center;
}

#task-preview {
  margin-top: 4px;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  background: #ffffff;
}

/* Basis für Shapes */
.shape {
  display: block;
}

/* Kachelfüllende Formen */
.shape-square {
  width: 100%;
  height: 100%;
  border-radius: 0;
}

.shape-circle {
  width: 100%;
  height: 100%;
  border-radius: 50%;
}

/* Dreiecke */
.shape-triangle-up,
.shape-triangle-down,
.shape-triangle-left,
.shape-triangle-right {
  width: 0;
  height: 0;
}

.shape-triangle-up {
  border-left: calc(var(--cell-size) / 2) solid transparent;
  border-right: calc(var(--cell-size) / 2) solid transparent;
  border-bottom: var(--cell-size) solid #111827;
}

.shape-triangle-down {
  border-left: calc(var(--cell-size) / 2) solid transparent;
  border-right: calc(var(--cell-size) / 2) solid transparent;
  border-top: var(--cell-size) solid #111827;
}

.shape-triangle-left {
  border-top: calc(var(--cell-size) / 2) solid transparent;
  border-bottom: calc(var(--cell-size) / 2) solid transparent;
  border-right: var(--cell-size) solid #111827;
}

.shape-triangle-right {
  border-top: calc(var(--cell-size) / 2) solid transparent;
  border-bottom: calc(var(--cell-size) / 2) solid transparent;
  border-left: var(--cell-size) solid #111827;
}

/* Raute */
.shape-diamond {
  width: 100%;
  height: 100%;
  border-radius: 0;
  transform: rotate(45deg) scale(0.7071); /* 1/sqrt(2) */
}

/* Punkt */
.shape-dot {
  width: 35%;
  height: 35%;
  border-radius: 50%;
}

/* Rechtecke */
.shape-rect-h {
  width: 100%;
  height: 50%;
  border-radius: 0;
}

.shape-rect-v {
  width: 50%;
  height: 100%;
  border-radius: 0;
}

/* Ellipsen */
.shape-ellipse-h {
  width: 100%;
  height: 60%;
  border-radius: 50%;
}

.shape-ellipse-v {
  width: 60%;
  height: 100%;
  border-radius: 50%;
}

/* Halbkreise */
.shape-semi-up,
.shape-semi-down,
.shape-semi-left,
.shape-semi-right {
  border-radius: 0;
}

.shape-semi-up,
.shape-semi-down {
  width: 100%;
  height: 50%;
}

.shape-semi-up {
  align-self: flex-start;
  border-radius: 50% 50% 0 0;
}

.shape-semi-down {
  align-self: flex-end;
  border-radius: 0 0 50% 50%;
}

.shape-semi-left,
.shape-semi-right {
  width: 50%;
  height: 100%;
}

.shape-semi-left {
  margin-right: auto;
  border-radius: 50% 0 0 50%;
}

.shape-semi-right {
  margin-left: auto;
  border-radius: 0 50% 50% 0;
}

/* Viertelkreise */
.shape-quarter-tl,
.shape-quarter-tr,
.shape-quarter-bl,
.shape-quarter-br {
  width: 50%;
  height: 50%;
}

.shape-quarter-tl {
  border-radius: 100% 0 0 0;
  align-self: flex-start;
  margin-right: auto;
}

.shape-quarter-tr {
  border-radius: 0 100% 0 0;
  align-self: flex-start;
  margin-left: auto;
}

.shape-quarter-bl {
  border-radius: 0 0 0 100%;
  align-self: flex-end;
  margin-right: auto;
}

.shape-quarter-br {
  border-radius: 0 0 100% 0;
  align-self: flex-end;
  margin-left: auto;
}

/* Diagonale Linien */
.shape-line-main,
.shape-line-anti {
  width: 140%;
  height: 12%;
  border-radius: 999px;
}

.shape-line-main {
  transform: rotate(45deg);
}

.shape-line-anti {
  transform: rotate(-45deg);
}

/* Exportbereich */
.panel-export textarea {
  width: 100%;
  margin-top: 8px;
  padding: 8px;
  font-family: "Consolas", "Courier New", monospace;
  font-size: 0.78rem;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  resize: vertical;
}

/* Footer */
.app-footer {
  padding: 8px 16px 14px;
  font-size: 0.75rem;
  color: #6b7280;
  text-align: center;
}

/* Responsiv */
@media (max-width: 960px) {
  .app-main {
    grid-template-columns: 1fr;
  }

  .panel-grid {
    order: -1;
  }

  .grid {
    margin: 0 auto;
  }
}

/* ===========================
   FOOTER – KachelKunst
=========================== */
.kk-footer {
  margin-top: 20px;
  padding: 18px 16px;
  background: #111827;
  color: #f3f4f6;
  text-align: center;
  font-size: 0.85rem;
  border-top: 1px solid #1f2937;
}

.kk-footer-main {
  margin-bottom: 6px;
}

.kk-subline {
  display: block;
  font-size: 0.75rem;
  opacity: 0.85;
  margin-top: 2px;
}

.kk-footer-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
}

.kk-footer-links a {
  color: #e5e7eb;
  text-decoration: none;
  font-size: 0.82rem;
  border-bottom: 1px solid transparent;
  padding-bottom: 2px;
}

.kk-footer-links a:hover {
  border-color: #e5e7eb;
}

