body,
html {
  margin: 0;
  padding: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.main {
  flex: 1;
  display: flex;
}

.column {
  display: flex;
  flex-direction: column;
}
.row {
  display: flex;
}

#left-panel {
  display: flex;
  flex-direction: column;
  width: 20%;
  max-width: 250px;
  padding: 10px;
  background-color: #f0f0f0;
  border-right: 1px solid #ccc;
}
h2.title {
  margin-top: 0;
}
.spread {
  display: flex;
  justify-content: space-between;
  align-items: start;
}

#object-items {
  flex: 1;
  overflow: auto;
  list-style: none;
  padding: 0;
  margin: 10px 0;
}
#object-items li {
  padding: 4px;
  cursor: pointer;
}
#object-items li.selected {
  background-color: #e0e0e0;
}
#object-items li:hover {
  background-color: #a0a0c0;
}
#save-file {
  margin: 0 10px;
}
#clear-canvas {
  color: red;
}

#canvas-container {
  display: flex;
  flex-grow: 1;
  overflow: hidden;
  position: relative;
}

#canvas {
  position: absolute;
}
#canvas:active {
  border: 0;
}

#tool-panel {
  position: absolute;
  z-index: 1;
  display: flex;
  padding: 10px;
  background-color: #f0f0f0;
}
#tool-panel .tool-button {
  margin-right: 10px;
}
#tool-panel #load-image {
  margin-right: 10px;
}

#properties-panel {
  display: flex;
  flex-direction: column;
  width: 20%;
  padding: 10px;
  max-width: 400px;
  background-color: #f0f0f0;
  border-left: 1px solid #ccc;
}

#ai-panel {
  display: flex;
  flex-direction: column;
  width: 24%;
  max-width: 360px;
  padding: 0 10px;
  overflow: auto;
  height: calc(100vh - 32px);
  background-color: #faf8ef;
  border-left: 1px solid #d3cbb2;
}

.ai-panel-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ai-panel-card textarea {
  width: 100%;
  resize: vertical;
  box-sizing: border-box;
}

.ai-preview pre {
  white-space: pre-wrap;
  background: #fffdf5;
  border: 1px solid #d3cbb2;
  padding: 10px;
}

.ai-results ul {
  padding-left: 20px;
}

.ai-results .ok {
  color: #22643a;
}

.ai-results .error,
.ai-error {
  color: #9b1c1c;
}

.mode-link {
  display: inline-block;
  margin-top: 10px;
}
#properties-panel input[type="text"],
input[type="number"] {
  flex: 1;
}

#properties-panel .type {
  margin-top: 10px;
  margin-bottom: 4px;
}

#properties-panel .row {
  margin: 3px 0;
  align-items: center;
}

#properties-panel .label {
  width: 100px;
  min-width: 100px;
}

#properties-panel .justify-buttons {
  margin-top: 10px;
}

#properties-panel .justify-button {
  height: 30px;
  width: 30px;
}

#footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 30px;
  border-top: 1px solid #ccc;
}

#footer #history {
  display: flex;
  flex: 1;
  align-items: center;
}

#footer .logo {
  margin: 0 10px;
}
#footer .gh {
  margin: 0 10px;
}

.history-square {
  width: 20px;
  height: 20px;
  margin: 2px;
  border: 1px solid #ccc;
  cursor: pointer;
}
.history-square.forward {
  background-color: white !important;
}
.history-square.add {
  background-color: #0f0;
}
.history-square.update {
  background-color: #ccc;
}
.history-square.remove {
  background-color: #f00;
}

.history-square:hover {
  background-color: #aaa;
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
}

.modal-content {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  background: white;
  padding: 20px;
  z-index: 1000;
  width: 600px;
  max-height: 80%;
}

.modal-content .font-list {
  flex: 1;
  overflow-y: auto;
  margin: 10px 0;
}

.font-item {
  margin: 15px 0;
  cursor: pointer;
}

.font-item:hover {
  background: #f0f0f0;
}

.font-item.selected {
  border-color: #007bff;
  background: #e7f3ff;
}

@media (max-width: 1100px) {
  .main.ai-mode {
    flex-wrap: wrap;
  }

  #left-panel,
  #properties-panel,
  #ai-panel {
    width: 100%;
    max-width: none;
  }

  #canvas-container {
    min-height: 420px;
    width: 100%;
  }
}
