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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background-color: #f5f5f5;
  padding: 12px;
  line-height: 1.4;
}

/* Status Bar Placeholder */
.status-bar-placeholder {
  background-color: #1da1f2; /* Twitter blue */
  height: env(safe-area-inset-top);
  position: sticky;
  top: 0;
  z-index: 999; /* Ensure it stays above other content */
}

/* Login Screen */
.login-screen {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
}

.login-container {
  background: white;
  padding: 40px;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  width: 100%;
  max-width: 400px;
}

.login-container h1 {
  text-align: center;
  margin-bottom: 30px;
  color: #333;
}

.login-container form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.login-container input {
  padding: 12px;
  border: 2px solid #ddd;
  border-radius: 4px;
  font-size: 15px;
  font-family: inherit;
  transition: border-color 0.2s;
}

.login-container input:focus {
  outline: none;
  border-color: #1da1f2;
}

.login-container button {
  background-color: #1da1f2;
  color: white;
  border: none;
  padding: 12px;
  border-radius: 4px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s;
}

.login-container button:hover {
  background-color: #1a91da;
}

.login-error {
  color: #e74c3c;
  font-size: 14px;
  text-align: center;
  min-height: 20px;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.nav-wrapper {
  position: relative;
  flex: 1;
  overflow: hidden; /* Ensure fade doesn't spill out if that happens */
}

.nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  /* position: relative; Removed, wrapper handles context */
}

.nav button {
  background: none;
  border: 1px solid #ddd;
  color: #666;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap; /* Prevent buttons from breaking lines */
}

.nav button.active {
  background-color: #1da1f2;
  color: white;
  border-color: #1da1f2;
}

.container {
  max-width: 600px;
  margin: 0 auto;
  background: white;
  padding: 16px;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

#editors-container {
  margin-bottom: 10px;
}

.tweet-editor {
  margin-bottom: 10px;
  padding: 5px;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  background-color: #fafafa;
}

.tweet-editor-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.remove-btn {
  background: none;
  border: none;
  color: #e74c3c;
  cursor: pointer;
  font-size: 12px;
  padding: 4px 8px;
}

.remove-btn:hover {
  text-decoration: underline;
}

.tweet-editor textarea {
  width: 100%;
  min-height: 60px;
  padding: 10px;
  border: 2px solid #ddd;
  border-radius: 4px;
  font-size: 15px;
  font-family: inherit;
  resize: none;
  overflow: hidden;
  transition: border-color 0.2s;
}

.tweet-editor textarea:focus {
  outline: none;
  border-color: #1da1f2;
}

.tweet-editor textarea.over-limit {
  border-color: #e74c3c;
}

.char-counter {
  text-align: right;
  font-size: 13px;
  color: #666;
}

.char-counter.over-limit {
  color: #e74c3c;
  font-weight: 600;
}

.add-btn {
  background-color: #f0f0f0;
  color: #333;
  border: 1px solid #ddd;
  padding: 8px 16px;
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
  margin-bottom: 10px;
  transition: background-color 0.2s;
}

.add-btn:hover {
  background-color: #e0e0e0;
}

.button-group {
  display: flex;
  gap: 12px;
  width: 100%;
  flex-wrap: wrap;
}

.clear-btn {
  flex: 0 0 auto;
  background-color: #fff;
  color: #e74c3c;
  border: 1px solid #e74c3c;
  padding: 10px 20px;
  border-radius: 4px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.clear-btn:hover {
  background-color: #e74c3c;
  color: white;
}

.save-draft-btn, .add-hopper-btn {
  background-color: #fff;
  color: #666;
  border: 1px solid #ddd;
  padding: 10px 20px;
  border-radius: 4px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.save-draft-btn:hover, .add-hopper-btn:hover {
  background-color: #f5f5f5;
  border-color: #999;
}

.post-btn {
  flex: 1;
  background-color: #1da1f2;
  color: white;
  border: none;
  padding: 10px;
  border-radius: 4px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s;
}

.post-btn:hover:not(:disabled) {
  background-color: #1a91da;
}

.post-btn:disabled {
  background-color: #ccc;
  cursor: not-allowed;
}

#result-area {
  margin-top: 10px;
  padding: 12px;
  border-radius: 4px;
  font-size: 13px;
  font-family: monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

#result-area:empty {
  display: none;
}

#result-area.success {
  background-color: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

#result-area.error {
  background-color: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

#result-area.loading {
  background-color: #d1ecf1;
  color: #0c5460;
  border: 1px solid #bee5eb;
}

/* Screens */
.tweets-screen h2, .drafts-screen h2, .hopper-screen h2, .settings-screen h2 {
  font-size: 1.2rem;
  margin-bottom: 1rem;
}

.tweets-list, .drafts-list, .hopper-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tweet-item {
  background-color: #fafafa;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 12px;
  position: relative;
}

.tweet-item p {
  white-space: pre-wrap;
  word-break: break-word;
}

.tweet-meta {
  font-size: 0.8rem;
  color: #666;
  margin-top: 8px;
  display: flex;
  justify-content: space-between;
}

.thread {
  border: 1px solid #ccc;
  border-radius: 6px;
  padding: 10px;
}

.thread .tweet-item:not(:last-child) {
  margin-bottom: 10px;
  border-bottom: 1px solid #eee;
  padding-bottom: 10px;
}

/* Drafts & Hopper Screens */
.draft-item, .hopper-item {
  background-color: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 12px;
}

.draft-preview p, .hopper-preview p {
  margin-bottom: 8px;
  font-size: 14px;
  color: #333;
  background: #f9f9f9;
  padding: 8px;
  border-radius: 4px;
}

.draft-meta, .hopper-meta {
  font-size: 0.8rem;
  color: #666;
  margin-top: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.draft-actions button, .hopper-actions button {
  background: none;
  border: 1px solid #ddd;
  color: #333;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  margin-left: 8px;
}

.draft-actions button:hover, .hopper-actions button:hover {
  background-color: #f0f0f0;
}

/* Settings Screen */
.settings-content hr {
  margin: 2rem 0;
  border: none;
  border-top: 1px solid #eee;
}

.settings-content .logout-btn {
  background-color: #e74c3c;
  color: white;
  border: none;
  padding: 10px 20px;
  font-size: 15px;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
}

.settings-content .logout-btn:hover {
  background-color: #c0392b;
}

.hopper-settings {
  margin-bottom: 2rem;
}

.hopper-settings h3 {
  margin-bottom: 1rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.form-group input, .form-group select {
  width: 100%;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
}

.posting-window-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.posting-window-item input {
  width: 60px;
}

.save-settings-btn {
  background-color: #1da1f2;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 4px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.save-settings-btn:disabled {
  background-color: #ccc;
  cursor: not-allowed;
}


.loader {
  text-align: center;
  padding: 20px;
  color: #666;
}


/* Mobile responsive styles */
@media (max-width: 768px) {
  .nav {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-right: 20px; /* Space for the fade */
  }

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

  .nav-wrapper::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 20px;
    background: linear-gradient(to left, white, rgba(255, 255, 255, 0));
    pointer-events: none;
    z-index: 10;
  }
  
  body {
    padding: 0;
  }

  .container {
    padding: 1rem;
    border-radius: 0;
    box-shadow: none;
  }

  .tweet-editor {
    padding: 5px;
  }

  .tweet-editor textarea {
    min-height: 80px;
    font-size: 16px; /* Prevent iOS zoom on focus */
  }

  .add-btn {
    width: 100%;
    padding: 12px;
    font-size: 16px;
  }

  .button-group {
    flex-direction: column;
    gap: 10px;
  }

  .clear-btn,
  .post-btn,
  .save-draft-btn,
  .add-hopper-btn {
    width: 100%;
    flex: none;
  }

  #result-area {
    font-size: 12px;
    padding: 12px;
  }
}

/* Extra small mobile */
@media (max-width: 400px) {
  .container {
    padding: 0.75rem;
  }

  .tweet-editor-label {
    font-size: 14px;
  }

  .remove-btn {
    font-size: 12px;
  }
}
