:root {
  --primary-color: #4a90e2;
  --bg-color: #f5f7fa;
  --panel-bg: #ffffff;
  --border-color: #e1e4e8;
  --text-color: #333;
}

* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  margin: 0;
  padding: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  width: 100%;
  display: flex;
  flex-direction: column;
  height: 100%;
}

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

header h1 {
  margin: 0 0 10px 0;
  font-size: 1.5rem;
}

header p {
  margin: 0;
  color: #666;
  font-size: 0.9rem;
}

/* Config Section */
#config-section {
  position: relative;
  background: var(--panel-bg);
  padding: 40px 15px 15px 15px; /* Adjusted padding-top */
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  margin-bottom: 20px;
  border: 1px solid var(--border-color);
}

#rules-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px; /* Adjusted margin-top */
}

#add-rule-btn {
  /* Removed absolute positioning */
  margin: 10px auto 0 auto; /* Center-align below rules container */
  display: block;
}

.config-buttons-top-right {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  gap: 10px;
}

.rule-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.rule-row input {
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  flex: 1;
}

.rule-row .arrow {
  color: #999;
  font-weight: bold;
}

.icon-btn {
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s;
  padding: 0;
}

.icon-btn:hover {
  background-color: #357abd;
}

.icon-btn .material-icons {
  font-size: 20px;
}

/* Editor Section */
#editor-container {
  display: flex;
  gap: 20px;
  flex: 1;
  min-height: 0; /* Important for nested flex scrolling */
}

.text-panel {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--panel-bg);
  padding: 15px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.text-panel label {
  font-weight: bold;
  margin-bottom: 0; /* Handled by panel-header */
  display: block;
}

.clear-btn {
  /* No absolute positioning here, it's part of flex flow */
}

.clear-btn:hover {
  background-color: rgba(0,0,0,0.1);
}

.clear-btn .material-icons {
  font-size: 18px;
}

textarea {
  flex: 1;
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border-color); /* Removed padding-top here */
  border-radius: 4px;
  resize: none; /* We control size via flex */
  font-family: monospace;
  font-size: 14px;
  line-height: 1.5;
}

textarea:focus {
  outline: 2px solid var(--primary-color);
  border-color: transparent;
}

.char-count {
  text-align: right;
  font-size: 0.8rem;
  color: #888;
  margin-top: 5px;
}

@media (max-width: 768px) {
  #editor-container {
    flex-direction: column;
  }
  
  .text-panel {
    min-height: 300px;
  }
}