* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: #f5f6fa;
  min-height: 100vh;
  line-height: 1.6;
  color: #2c3e50;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

header {
  text-align: center;
  margin-bottom: 30px;
}

header h1 {
  font-size: 2rem;
  margin-bottom: 8px;
  color: #2c3e50;
  font-weight: 600;
}

header p {
  font-size: 1rem;
  color: #7f8c8d;
}

.main-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 20px;
}

.bottom-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.editor-panel,
.token-panel,
.error-panel-wrapper {
  background: white;
  border-radius: 8px;
  border: 1px solid #e1e8ed;
  overflow: hidden;
}

.editor-panel h2,
.token-panel h2 {
  background: #f8f9fa;
  color: #2c3e50;
  padding: 15px 20px;
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  border-bottom: 1px solid #e1e8ed;
}

.editor-container {
  position: relative;
  background: #2c3e50;
  height: 400px;
  display: flex;
  overflow: hidden;
}

#line-numbers,
.code-input,
#highlighted-code,
#errors,
.token-item {
  font-family: "SF Mono", "Monaco", "Inconsolata", "Roboto Mono", monospace;
}

#line-numbers {
  background: #34495e;
  color: #95a5a6;
  padding: 15px 10px;
  font-size: 14px;
  line-height: 1.5;
  text-align: right;
  min-width: 50px;
  user-select: none;
  border-right: 1px solid #40566b;
  overflow-y: hidden;
}

.line-number {
  height: 21px;
  line-height: 1.5;
}

.editor-wrapper {
  position: relative;
  flex: 1;
  overflow: hidden;
}

.code-input {
  width: 100%;
  height: 100%;
  padding: 15px;
  border: none;
  background: transparent;
  color: transparent;
  caret-color: #fff;
  font-size: 14px;
  line-height: 1.5;
  resize: none;
  outline: none;
  white-space: pre;
  overflow-wrap: break-word;
  z-index: 2;
  position: relative;
  overflow: auto;
}

#highlighted-code {
  position: absolute;
  top: 0;
  left: 0;
  padding: 15px;
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: #ecf0f1;
  background: transparent;
  white-space: pre;
  overflow-wrap: break-word;
  pointer-events: none;
  z-index: 1;
  width: 100%;
  height: 100%;
}

.keyword {
  color: #9b59b6;
  font-weight: 600;
}
.string {
  color: #2ecc71;
}
.number {
  color: #e74c3c;
}
.comment {
  color: #95a5a6;
  font-style: italic;
}
.operator {
  color: #f39c12;
}
.identifier {
  color: #ecf0f1;
}
.delimiter {
  color: #e67e22;
}

#error-panel {
  margin: 0;
  padding: 20px;
  background: white;
  border-radius: 8px;
  border: 1px solid #e1e8ed;
  height: 100%;
}

#error-panel h3 {
  background: #f8f9fa;
  color: #e74c3c;
  padding: 15px 20px;
  margin: -20px -20px 15px -20px;
  font-size: 1.1rem;
  font-weight: 600;
  border-bottom: 1px solid #e1e8ed;
}

#errors {
  font-size: 13px;
}

.error-item {
  background: #fef5f5;
  border: 1px solid #f5c6cb;
  color: #e74c3c;
  padding: 10px 15px;
  margin-bottom: 8px;
  border-radius: 4px;
  border-left: 3px solid #e74c3c;
}

.token-panel {
  max-height: 600px;
}

#token-list {
  max-height: 500px;
  overflow-y: auto;
  padding: 15px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.token-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: #f8f9fa;
  border-radius: 20px;
  border: 1px solid #e1e8ed;
  font-size: 12px;
  transition: all 0.2s ease;
  cursor: default;
}

.token-item:hover {
  background: #e9ecef;
  transform: translateY(-1px);
}

.token-value {
  font-weight: 500;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #2c3e50;
}

.token-type {
  padding: 2px 6px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: white;
}

.token-type.keyword {
  background: #9b59b6;
}

.token-type.string {
  background: #2ecc71;
}

.token-type.number {
  background: #e74c3c;
}

.token-type.comment {
  background: #95a5a6;
}

.token-type.operator {
  background: #f39c12;
}

.token-type.identifier {
  background: #6c757d;
}

.token-type.delimiter {
  background: #e67e22;
}

.legend {
  background: white;
  border-radius: 8px;
  padding: 20px;
  border: 1px solid #e1e8ed;
}

.legend h3 {
  margin-bottom: 15px;
  color: #2c3e50;
  font-size: 1.1rem;
  font-weight: 600;
}

.legend-items {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: #2c3e50;
}

.color-box {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  display: inline-block;
}

.color-box.keyword {
  background-color: #9b59b6;
}
.color-box.string {
  background-color: #2ecc71;
}
.color-box.number {
  background-color: #e74c3c;
}
.color-box.comment {
  background-color: #95a5a6;
}
.color-box.operator {
  background-color: #f39c12;
}
.color-box.identifier {
  background-color: #ecf0f1;
  border: 1px solid #bdc3c7;
}
.color-box.delimiter {
  background-color: #e67e22;
}

@media (max-width: 1024px) {
  .bottom-panels {
    grid-template-columns: 1fr;
  }

  .legend-items {
    justify-content: center;
  }
}

@media (max-width: 768px) {
  .container {
    padding: 15px;
  }

  header h1 {
    font-size: 1.8rem;
  }

  .code-input,
  #highlighted-code {
    font-size: 13px;
  }

  .bottom-panels {
    grid-template-columns: 1fr;
  }
}
