:root {
  /* Color Palette - Premium & Soft */
  --primary-color: #2c3e50;
  /* Deep Slate - More Professional */
  --primary-light: rgba(44, 62, 80, 0.05);
  --primary-dark: #1a252f;
  --accent-color: #3498db;
  /* Calm Blue */

  /* Neutral Colors */
  --bg-color: #f8f9fa;
  /* Very Light Grey */
  --text-color: #333333;
  --text-muted: #666666;

  /* Background and Surface */
  --surface-color: #ffffff;
  --sidebar-bg: #fdfdfd;

  /* Sidebar */
  --sidebar-text: #999;
  --sidebar-width: 50px;

  /* Buttons */
  --button-bg: var(--primary-color);
  --button-hover: var(--primary-dark);
  --button-text: white;

  /* Tabs */
  --tab-bg: #eceff1;
  --tab-active-bg: #ffffff;
  --tab-hover-bg: #f4f6f7;
  --tab-border: #dfe6e9;
  --tab-height: 40px;
  /* Slightly taller for modern look */

  /* Status Bar */
  --status-bar-bg: #ffffff;
  --status-bar-text: #7f8c8d;
  --status-height: 36px;

  /* Typography */
  --font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --editor-font-family: 'Noto Sans JP', sans-serif;
  /* Use Noto for editor too for Japanese consistency, or a good monospace if needed */
  --editor-font-size: 16px;
  --line-height: 1.8;
  /* More breathing room */

  /* Sizing and Spacing */
  --toolbar-height: 56px;
  --border-radius: 6px;
  --border-radius-sm: 4px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.05);

  /* Borders */
  --border-color: #e0e0e0;

  /* Transitions */
  --transition-speed: 0.2s;

  /* Scrollbars */
  --scrollbar-thumb: #bdc3c7;
  --scrollbar-thumb-hover: #95a5a6;
}

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

body,
html {
  height: 100%;
  width: 100%;
  overflow: hidden;
  background-color: var(--bg-color);
  color: var(--text-color);
  font-family: var(--font-family);
  -webkit-font-smoothing: antialiased;
}

.container {
  display: flex;
  height: 100%;
  width: 100%;
  position: relative;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  overflow-y: hidden;
  user-select: none;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 5;
  border-right: 1px solid var(--border-color);
}

.sidebar-toolbar-space {
  height: calc(var(--toolbar-height) + var(--tab-height));
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 14px;
}

.sidebar-icon {
  width: 28px;
  height: 28px;
  opacity: 0.8;
  filter: grayscale(100%);
  /* Minimalist icon */
  transition: opacity 0.2s;
}

.sidebar-icon:hover {
  opacity: 1;
}

.line-numbers {
  padding: 20px 8px 20px 0;
  text-align: right;
  color: var(--sidebar-text);
  font-size: 12px;
  overflow-y: hidden;
  flex: 1;
  width: 100%;
  white-space: pre;
  font-family: inherit;
  /* Match editor font */
}

.line-number {
  height: calc(var(--line-height) * var(--editor-font-size));
  line-height: calc(var(--line-height) * var(--editor-font-size));
  display: block;
}

/* Editor container */
.editor-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  width: 100%;
  margin-left: var(--sidebar-width);
}

/* Toolbar */
.toolbar {
  display: flex;
  padding: 0 24px;
  background-color: var(--surface-color);
  border-bottom: 1px solid var(--border-color);
  justify-content: space-between;
  align-items: center;
  height: var(--toolbar-height);
  width: 100%;
  z-index: 10;
}

/* App title */
.app-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary-color);
  letter-spacing: -0.02em;
}

/* Tab system styling */
.tab-container {
  display: flex;
  background-color: #f2f4f6;
  /* Distinct from toolbar */
  border-bottom: 1px solid var(--border-color);
  overflow-x: auto;
  height: var(--tab-height);
  align-items: flex-end;
  width: 100%;
  padding-left: 0;
}

.tabs {
  display: flex;
  height: 100%;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
  align-items: stretch;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  display: flex;
  align-items: center;
  padding: 0 16px;
  background-color: var(--tab-bg);
  border-right: 1px solid var(--tab-border);
  height: 34px;
  /* Unselected height */
  min-width: 120px;
  max-width: 200px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  position: relative;
  user-select: none;
  margin-top: 6px;
  /* Push down */
  border-top-left-radius: 6px;
  border-top-right-radius: 6px;
  transition: all 0.15s ease;
}

.tab.active {
  background-color: var(--tab-active-bg);
  height: 40px;
  /* Full height */
  margin-top: 0;
  z-index: 1;
  font-weight: 500;
  color: var(--text-color);
  box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.02);
}

.tab:hover:not(.active) {
  background-color: var(--tab-hover-bg);
}

.tab-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tab-title-input {
  flex: 1;
  height: 20px;
  font-size: 13px;
  border: none;
  background: transparent;
  border-bottom: 1px solid var(--accent-color);
  outline: none;
  padding: 0;
  margin-right: 8px;
  width: calc(100% - 25px);
  font-family: inherit;
}

.tab-close {
  margin-left: 10px;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 16px;
  line-height: 1;
  opacity: 0;
  /* Hidden by default for cleaner look */
  transition: all 0.2s;
}

.tab:hover .tab-close,
.tab.active .tab-close {
  opacity: 0.6;
}

.tab-close:hover {
  background-color: rgba(0, 0, 0, 0.1);
  opacity: 1 !important;
}

.new-tab-btn {
  width: 36px;
  height: 34px;
  background-color: transparent;
  color: var(--text-muted);
  border: none;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 6px;
  transition: all 0.2s;
}

.new-tab-btn:hover {
  color: var(--accent-color);
  background-color: rgba(0, 0, 0, 0.03);
}

/* Button styles */
.file-actions {
  display: flex;
  gap: 10px;
}

.btn {
  padding: 8px 18px;
  background-color: var(--button-bg);
  color: var(--button-text);
  border: none;
  border-radius: var(--border-radius);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s ease;
  letter-spacing: 0.02em;
}

.btn:hover {
  background-color: var(--button-hover);
  transform: translateY(-1px);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.btn:active {
  transform: translateY(0);
}

.btn-outline {
  background-color: transparent;
  color: var(--text-color);
  border: 1px solid var(--border-color);
}

.btn-outline:hover {
  background-color: white;
  border-color: var(--accent-color);
  color: var(--accent-color);
}

/* Editor area */
.editor-wrapper {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
  background-color: white;
}

#editor {
  flex: 1;
  padding: 24px 30px;
  font-size: var(--editor-font-size);
  line-height: var(--line-height);
  overflow-y: auto;
  border: none;
  resize: none;
  outline: none;
  background-color: white;
  font-family: var(--editor-font-family);
  color: var(--text-color);
}

/* Status bar */
.status-bar {
  display: flex;
  padding: 0 24px;
  background-color: var(--status-bar-bg);
  border-top: 1px solid var(--border-color);
  justify-content: space-between;
  /* Changed for help links */
  align-items: center;
  height: var(--status-height);
  width: 100%;
}

.stats {
  display: flex;
  gap: 24px;
  font-size: 12px;
  color: var(--status-bar-text);
  font-family: var(--font-family);
}

.help-links {
  font-size: 12px;
}

.help-links a {
  color: var(--status-bar-text);
  text-decoration: none;
  transition: color 0.2s;
}

.help-links a:hover {
  color: var(--accent-color);
  text-decoration: underline;
}

.help-links .separator {
  margin: 0 8px;
  color: #ddd;
}

/* Scrollbar styling */
#editor::-webkit-scrollbar {
  width: 10px;
  background-color: transparent;
}

#editor::-webkit-scrollbar-thumb {
  background-color: var(--scrollbar-thumb);
  border-radius: 10px;
  border: 3px solid white;
  /* padding effect */
}

/* Notification */
.notification {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 14px 24px;
  background-color: #2ecc71;
  /* Success Green */
  color: white;
  border-radius: 50px;
  /* Pill shape */
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  pointer-events: none;
  box-shadow: 0 5px 15px rgba(46, 204, 113, 0.3);
  z-index: 1000;
  font-weight: 500;
  font-size: 14px;
}

.notification.show {
  opacity: 1;
  transform: translateY(0);
}

#file-input {
  display: none;
}

/* Responsive styling */
@media (max-width: 768px) {
  :root {
    --editor-font-size: 15px;
    --sidebar-width: 0px;
    /* Hide sidebar numbers on mobile */
  }

  .sidebar {
    display: none;
  }

  .editor-container {
    margin-left: 0;
  }

  .toolbar {
    padding: 0 16px;
  }

  .file-actions {
    gap: 8px;
  }

  .btn {
    padding: 6px 12px;
    font-size: 12px;
  }

  .app-title {
    font-size: 16px;
  }

  #editor {
    padding: 16px;
  }

  /* Improved Status Bar for Mobile */
  .status-bar {
    height: auto;
    min-height: 60px;
    flex-direction: column;
    padding: 12px 16px;
    gap: 10px;
    align-items: center;
    justify-content: center;
  }

  .stats {
    gap: 16px;
    justify-content: center;
    width: 100%;
  }

  .help-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    width: 100%;
    text-align: center;
    line-height: 1.4;
  }

  .help-links .separator {
    display: none;
  }
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-color: #121212;
    --text-color: #ecf0f1;
    --text-muted: #bdc3c7;
    --surface-color: #1e1e1e;
    --sidebar-bg: #1e1e1e;
    --sidebar-text: #555;

    --primary-color: #ecf0f1;
    --primary-dark: #bdc3c7;

    --tab-bg: #121212;
    --tab-active-bg: #1e1e1e;
    --tab-border: #333;
    --tab-hover-bg: #252525;

    --status-bar-bg: #1e1e1e;
    --status-bar-text: #7f8c8d;

    --border-color: #333;

    --button-bg: #34495e;
    --button-text: #ecf0f1;
    --button-hover: #2c3e50;

    --scrollbar-thumb: #444;
  }

  .editor-wrapper,
  #editor {
    background-color: #1a1a1a;
    color: #ecf0f1;
  }

  #editor::-webkit-scrollbar-thumb {
    border: 3px solid #1a1a1a;
  }

  .btn-outline {
    color: #ecf0f1;
    border-color: #444;
  }

  .btn-outline:hover {
    background-color: #333;
    color: #fff;
    border-color: #555;
  }

  .tab-container {
    background-color: #121212;
  }

  .tab.active {
    background-color: #1a1a1a;
    color: white;
  }

  .new-tab-btn {
    color: #666;
  }

  .new-tab-btn:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: #ccc;
  }

  .tab-title-input {
    color: white;
  }
}